Yeah that would be a factor but there's more to that. For example the Japanese are so crafty with land use they even allow an odd type of development called Zakkyo. Which are multi-storey buildings wherein each floor is owned and managed independently. The foot traffic isn't restricted to the ground floor to enjoy these "third places".
IMO geographical constraints should not be the all-in justification for a certain land-use/housing policy. I hear a lot chalk up the fact Barcelona stopped building since the 1980s because they're surrounded by mountains and the sea. Or recently with the LA fires people look at these wrong answers. There's no reason for things being like that other than NIMBYism and lack of long-term political will from local councils.
Spain's multi-story buildings are often independently owned anyway: the "law of horizontal property", dealing with condominiums, is there to mostly deal with shared disputes among owners. Buildings where the ground floor is stores, the next three have small professional offices, all owning the space, and the rest is a collection of apartments occupied by their owners is very common where there's sufficient demand for said offices.
Barcelona's problems come from a very complicated regulatory regime that hasn't just lowered construction, but ultimately led to fewer people living in the same space. Regulations that favor the renter enough to make putting housing up for rent pretty risky in many ways. Minimal property taxes that let having an apartment unused be pretty attractive. Big tax advantages for owning an expensive apartment vs living in a smaller one and putting your savings into stocks. Prices that don't come down. A location so interesting, and yet at prices that are globally affordable, so it is more profitable to have an apartment dedicated to low-occupancy rate foreign tourism than to have it occupied all year long by a long term tenant. Cheap enough for an American in tech to buy an apartment downtown, and use it 3 weeks a year.
The market-centric changes that wouldn't just allow more building, but make the existing buildings be used more efficiently are just not in any local regulator's radar, because lowering prices might be nice for renters, but it'd be awful for owners, and there's a lot of those, and they vote.
Definitely, but I wanted to note a big thing that I often do not see mentioned in these kind of discussions. e.g. I'm looking at apartments in Tokyo, and for Japanese people one of the biggest decision factor is the age due to earthquake fears. Heck, I'd say it's the main factor not to buy, a big % of the people just won't buy older than X years. This is the most "unthinkable" thing in my Spaniard brain, since older houses are not inherently worse (they have both bad things and good things).
There's many other differences (and surprisingly, similarities) between Spain and Japan regarding buildings, e.g. the mixed areas are both very similar in both countries. But another surprising thing in (specifically) Tokyo is how strongly public transportation shapes Tokyo, go out in any train station and you have tall buildings, but walk 10-15 mins away and you have houses. In Spain, you have a very homogeneous height all across the city (fun fact: this was traditionally shaped by the cathedrals/churches).
IMO geographical constraints should not be the all-in justification for a certain land-use/housing policy. I hear a lot chalk up the fact Barcelona stopped building since the 1980s because they're surrounded by mountains and the sea. Or recently with the LA fires people look at these wrong answers. There's no reason for things being like that other than NIMBYism and lack of long-term political will from local councils.