I think this has nothing to do with defence and everything to do with Kowloon Walled City that was sort of a no law enclave where everything was built very high and shoulder to shoulder to maximize floor space.
Oh, I was just thinking of https://en.wikipedia.org/wiki/Walled_city, which describes nearly all cities for the past ten thousand years, though less so for the last 5% of that time.