Mountain passes hold the key to travelling among mountains. If you build a town in a pass, then you can make money by trading with travellers.
But, of course, a pass was therefore an important place and armies would try to capture it.
Glurns, in the Italian Alps, shows you what a walled town was like in the past and what it's like today.