Who assigns postal addresses?

Does anyone know how postal addresses are assigned in Spain? Is it the Town Hall/Local Police, the Post Office, Catastro or some other august body? I do not need to know - I'm just interested and Google doesn't seem able to help.

The reason it's on my mind is that I had a lot of trouble trying to complete a form from my UK bank, the HSBC, which wanted me to confirm my address.

We live a bit out of town, in a village, and our address varies from organisation to organisation depending of the strengths or weaknesses of their databases. Our post code is a bit of a movable feast too. Correos, as an organisation, is clear what our postcode is but the Correos staff in our local town told us to use the post code of that town and not the official one. It makes very little real difference until one lot of bureaucracy bumps into another.

I assume it is the town hall as their workmen have changed, what was my existing address, at a couple of  properties,

However, I once had a postman (man the woman was fine) who would not deliver unless the address was as he said it should be and I also had to have my name on my post box, which he said was a legal requirement.   

I showed all the name of my family, even those who lived in UK, about 9 names, just to be difficult !        I also knew it is possible to discover one's telephone number from the address and name and a would-be burglar could then call and if no reply know I was out.   I was though, as I had always been in UK,  ex-director for the same reason.

But,   I wanted my letters so I did as the postMAN wanted.

It's the town hall but that said when we asked they had no clue they even changed the names of the streets which is odd seeing as they were the ones who changed all the signs.
In the end they sent the local Policia around to confirm what the address was, 3 months later.

Makes me think it may of actually been the land registry as they like to change things about and the new names and stuff have to get into GPS maps and google maps somehow and that would appear to be above the town halls pay grade.

Maybe it is worth asking either at the town hall or local Policia station?

I think you will find that -land registry- as far as towns are concerned, is a department of the town hall, like the building control and Property Registry