It can be a little confusing to most newcomers to Spain, that there are three separate Police Forces that operate, with varying responsibilities.

The Guardia Civil Wear green uniforms and were generally feared during Franco's era due to their far reaching influence and control. These days they are responsible for national security, customs and for crowd control at large events. Their traffic department vehicles patrol the main highways with green and white coloured cars and motorbikes and organise radar speeding checks. They are very pro-active in setting up roadside checkpoints to check various documentation, so don't be alarmed if you are stopped at any time of the day or night - But remember that this is all the more reason to have your paperwork in order and kept in your glove compartment.
The National Police Wear a black uniform and white shirts. Some officers may wear a blue military uniform and sometimes armed as their duties include guarding public buildings and personnel. They are responsible for most day to day crime investigation and it is to them that you should go to make denunica for any crime that you may be a victim of. If any of your possessions (Like Credit Cards or Passport) have been lost or stolen they can provide you with the necessary documentation to supply to your Bank and / or your Insurance company.
The Local Municipal Police Wear blue and white uniforms and are basically Town Hall Officials. Their main responsibilities include Parking violations, guarding the street crossings at School times and upholding the local Bye Laws (Like Building & Safety regulations) in the Municipal area. Although they too are armed, they are very approachable by residents and Tourists alike as they are essentially working in the Interests of the local community.
In your dealings with any of the above Police Agencies it is important to be Polite and try your best to speak whatever Spanish you can as this more often than not helps to show that you are not just another "Disagreeable Foreigner" that thinks that a misunderstanding of the Language, or ignorance of the law is enough to resolve any situation.