Hemel Hempstead is unlikely to be Buckinghamshire's administrative town, seeing as it's in Hertfordshire! It is, as Quizmonkey says, based on where your nearest sorting office is, irrespective of county boundaries. I live in West Sussex, and as far as I know, there are no postcodes anywhere in the county that refer to towns actually in West Sussex.
For example, my postcode starts with PO, for Portsmouth (Hampshire). Other West Sussex postcodes begin with BN for Brighton (East Sussex), GU for Guildford (Surrey) and RH for Redhill (also Surrey).