When I was in Shanghai I was shocked at how a city with one million more people than the entire population of Taiwan (24 million vs. 23 million) could feel so uncrowded, but that’s because I didn’t realize just how big Shanghai is at the time. (The extensive subway system makes the city feel much smaller than it is.)
It is 6,340 km²! Taipei, by comparison is only 272 km², and while Taiwan in total is 36,193 km², 70% of that is mountains. The non-mountainous area of Taiwan only about 10,858 km², or less than double the size of Shanghai. Moreover, about 24% of Taiwan (8,686 km²) is agricultural land. It isn’t clear to me how much of that is in the mountains, but if we just subtract half of that land from the total we are down to 6,515 km² or about the area of Shanghai! (And it is probably even less than that since I’m pretty sure half the agricultural land isn’t in the mountains.)
While these numbers are far from being scientifically accurate, I think they give a sense as to why Shanghai felt less crowded than Taipei.