Castle is the place that you must either defend or destroy. Sometimes when all forces in the castle are defeated, the castle might be claimed as the players own. This is "Cede Castle" event cannot be put to normal maps.
Usually castle has a barracks and armory. Keep is also situated there usually in the best protected place. Sometimes Civilian buildings are outside the castle and military buildings inside the castle. This will make more room for military buildings but can easily devastate economy because enemies would hit the civilian buildings outside when they are invading the castle.
A good defensive procedure is to mount archers with braziers everywhere on the walls and the keep, put pikemen and swordsmen patrolling the keep, and have Knights patrol the outer rim of your castle. It costs a lot of gold, but it is a virtually unbreakable defensive strategy.