You can see an example of this defensive architecture in today's photo, taken inside the Kanazawa castle: the masugata complex includes two gates, the external gate on the right (a simpler, Koraimon type of gate), and the internal gate, larger and more complex (Yaguramon type) on the left. The rectangular space between the gates was used as a place to gather the defending troops, in order to initiate a surprise attack, and it was also a trap for the attackers, blocking their troops after conquering the first gate.
EXIF info:
Nikon Df
Lens: 14mm F/2.8D
Focal Length: 14mm
Aperture: F/7.1
Shutter Speed: 1/250s
ISO Sensitivity: ISO 400