East Asian Buddhist temples are composed from a range of functional buildings. The arrangement of these buildings changed in time and is slightly different per Buddhist sect. The scale and number of buildings changed depending on its importance and the landscape.
Considerable care went into the technology of the building that stored the Buddhist scriptures. Everything was focussed on fire prevention, considerable distance between the buildings helped prevent the spread of fire.
An ideal layout of a temple complex would result in a rectangular enclosure with the buildings arranged in symmetry along the central axe running South to North. All construction methods and layouts where based on Chinese design theory.
Temples had to facilitate several functions, foremost it is a place of study, meditation and preforming rituals but it also houses more pragmatic functions like administration, storage and the needs for daily life of the monks on the premises. Every part of this routine was given a separate building following the Chinese examples.
When Buddhism arrived in Japan its other religion Shinto was already established. Shinto performed rituals for marriages and rituals for new born. Death was not dealt with satisfactory in a religious context. Buddhism filled that niche in Japan and cemeteries and burial rituals became an important part of Buddhism and its acceptance in Japan.
Many Buddhist temples in modern Japan are hereditary whereby a son inherits the role of abbot from its parents. It can be a very lucrative business to own a temple and collect compensations for rituals performed at funerals. Combined with a tax-free status many temples collect large revenues.