Remember that the phone code of Spain is 0034
In each city of town you can find different Telephone Shops like Movistar, Vodafone, Orange, Yoigo, etc. where you can find all these services.
You have differents options of use: You can buy a prepaid card sim, or a contract card.
Normally in public libraries you can find free access to internet and also in some public spaces.