Castles were guarded by well trained knights and armed peasants. There were also archers that kept guard on top of the outer walls. Moats were used to hold off the attacking force for a few days, but they were mostly used to make the castle appear larger than it is. Pots of boiling water/oil were also used to slow down the enemy at the main entrances. Some castles also built a second line of defence which made it even more difficult for the attacking force to conquer the castle.
The stairs on the watch tower were also made to spiral clockwise which made it much easier for right handed people to defend the tower. Beneath the castle gates there were 'murder holes' which were used to drop hot sand, boiling tar or molten lead over the attacking army.