Why in the past were European ships built with high wooden "castles" fore and aft?
to manage the deck more easily
to improve ship stability
These were built to better resist boarding, commonly used in the naval warfare (especially by pirates). Boarders needed to attack these castles with great difficulty, while archers or harquebusiers could sweep the enemy decks.