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.
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.
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).
I want to note that this is in big part due to earthquakes and nature in general. In Spain 100-year old houses (like in the article) are renovated and relatively easy to maintain. However in Japan, between the earthquakes, typhoons, and the weather in general, not only you need to be actively maintaining it (typhoons), but they become worse over time (earthquake damage accumulates).
Source: Spaniard who lives in Tokyo.