The entire design of a castle was designed to provide for the defense of its inhabitants. A castle was meant to be an impregnable fortress that could house many fighters. Those fighters could then dominate the region of the castle.
Some features of many castles included:
- Being built on high ground that was hard to approach. This made it harder for massive armies to get near the castle.
- Having thick walls. These could be as thick as 10 feet.
- Having firing positions and other features that allowed defenders to attack from cover. These were things like arrow slits through which defenders could fire without being exposed to enemy fire themselves.
Think also about the designs of castles changed to be defensive as technology changed. Towers became round instead of square to encourage projectiles to bounce off.
Also, stairs in early castles tend to be straight but move onto being spiral straircases. This wasn't just to look fancy and to save space but a stair that span up in a clockwise direction made it impossible for a right handed attacker to weild their sword as they climbed the stairs.