Except when it doesn’t, of course! This [0] post has some examples of interesting post codes. They’re really more just a collection of addresses that are usually near each other, but require you to know the area. So much fun!
Well, how many buildings, and of what sort, varies enormously, but yes it won't be a whole town or region.
Most of my street is a single post code. Once upon a time it was a street of single family dwellings, so that's maybe a 3-4 dozen homes, but this is a city suburb so densification means some of those homes were modified and cut up to form flats, one large family home becomes six smaller homes - and some were purchased, knocked down and replaced by buildings which don't look out of place but aren't what they were before. I live in a purpose built four storey block, but it's designed to look superficially like a big house, the bottom floor is below street level (it faces out over the hill), the top has only loft-style windows at the front like somebody did a loft conversion.
It's all still one postcode though, so I share a code with maybe 100+ households. Recoding is disruptive and it's not really worth it, so they mostly don't do it.
Remember for actually delivering the post the postcode is just a convenient human readable part of an address, the machines (with occasional human help) turn any arbitrary address into a unique destination code, and then that's literally barcoded (albeit not in a code you're used to from like UPC etc.) onto the post. So for the Royal Mail the postcodes not being as descriptive as they were fifty years ago isn't a big problem.
Take some mail you've received, preferably over several days and study the outsides carefully. Two fluorescent orange bar codes have been jet printed onto the mail during sorting. The upper code is "just" a temporary unique ID, every piece of mail in the sorting system is issued a code, when they run out they start over, this helps with debugging and statistics. The lower case is in some sense the successor to the postcode, it'll be identical for every item delivered to the same address and distinct for other addresses. In fact it's encoding the "Delivery Point" which is what PAF handles, the location to which the Royal Mail employee delivers mail. https://en.wikipedia.org/wiki/RM4SCC
The use of these "real" postcodes also enables the Royal Mail to more readily accede to impractical "vanity" postcode requests. If the rich people in this part of Dirt Town think they ought to have postcodes from the adjacent and posh sounding Upper Niceton, RM can allow that, because in reality their teams are working from the purely numeric code which will still treat all these new "Upper Niceton" homes as being where they actually are, in Dirt Town.
The British mail addresses are pretty interesting. We quickly learned that, as you say some postcode have just one or two houses, which may not have numbers, but names.
I'm sure there is a "falsehoods programmers believe about addresses" somewhere.
Kilshandra is a town, the townland for Lakeview would likely be "Portaliff or Townparks". Though to be somewhat fair, Lakeview in Kilshandra is really only unique vs things like "Pond View", "Lough View" or "Yet another body of water view".
In Meath, there's a House address near Garlow Cross where it's Foo House, Johnstown, Co Meath, but Johnstown is 7km away or so.
For those who have not been near there -- It's karst topography with basket of eggs hills where the water table is above ground in many of the valleys.
Amazing. For a e-commerce site I argued that we would save ourself a lot of trouble by simply making the address field one large text field, rather than attempt to making a form that would work for every country and city (looking at you Mannheim).
But apparently that would make data analysis to complicated.
There is a middle ground and some common patterns that can help.
The address field names are fairly standardized[0] and Google has an open dataset (used by Chrome and Android) describing which countries need which fields[1].
I have an older PHP library[2] and a newer Go library[3] that build upon this, while crowdsourcing fixes (since Google hasn't updated their dataset in a while). The Go library allows me to serve all address formats and state lists in a single HTTP request, which can then power a very fast JS widget.
[0] Initially by the OASIS eXtensible Address Language (xAL) which trickled down into everything from maps to HTML5 autocomplete.