Lots of people in Edinburgh live in tenements - separate flats off a common stair, or 'close'. This is partly a historic thing: in the 16th and 17th centuries there was very little space to build in the Old Town, because of its geographical location on a narrow ridge of rock. Instead, people built upwards, which resulted in high, densely populated buildings. Incidentally, the Scottish Enlightenment was very much a product of this type of housing as different classes, professions and intellectual ideas all coexisted at very close proximity.
Nowadays tenement living is still very much part of Edinburgh culture, and with these tenements often come shared gardens at the back of the buildings, all bordering on each other like in the photo above.