Anyway, just to add onto this (although this was said before)
If you want to defend your castle once you captured it, you have to lure an enemy party to the castle gates, then just as they are about to attack you, select "rest" in the castle. The party would then siege the castle walls with you in them. Take note however, that the only troops that fight with you, would be the ones in your party - NOT the ones stationed at the castle during that time.