Hi Benok,
First you have to go to get a medical check up for underwater activities. To do this you need a (blank) medical certificate which you get at a tobacco/stamp shop for a couple of euros. Find a doctor that can give you this type of checkup and (around 20-40 euros) Then you go to the local Ministerio of Ramaderia y Pesca office for the actual licence which is valid for all of Spain (approx 13 euros). The town hall would probably be able to inform you of the location of the Ministry building. If you are in a small town it might be in the next larger one. You will also need diving insurance, to show to the police if you would ever be stopped and asked for documentation. As you would if you were scuba diving.
When you get in the water you need to have on you the spearing licence, the dive insurance and a national ID card of some sort. In Spain all of these are plasticized and are the size of credit cards, so I used to have them hanging off my float in a little watertight container.
Fines can run from 600 euros up plus confiscation of all your equipment.
All this is only for spearfishing, if you aren't going to do this, then there is no official paperwork involved.
I hope this helps. Good luck and Welcome to Deeper Blue!