>>64444334
aside from their use as a point of shelter in case or a raid or a hostile army passing by that other annons have already pointed out.
they are first and foremost a social thing, a declaration of status. to those under you it is a very real set in stone way of showing you are better than them, you are richer than them and that they can't do shit against you because once you close your gate they aren't getting in. to your peers having a castle of any sort means you are in the club. sure you might be a bottom feeder compared to the big guys but at least you are in the same club as them.
militarily you can in a pinch squeeze in half a dozen horses and two dozen men at arms.
that means that you can harass forage parties intercept communications ect. you can be annoying
an invader now has to chose how it's going to deal with that annoyance.
you can ignore it and accept that you are going to lose some smaller forage parties
you can send a detachment of men to put it under siege just to bottle them up
you can try to offer them terms or to bribe them
you can try and take the castle
ect. ect.
all of those cost you something, men, resources, attention, time, money
and along your route of march to where you want to go because it is important there will be half a dozen or more of these. once you get where you want to go there will be half a dozen around that to that you are going to have to deal with
everyone of them requiring a decision and imposing a cost
it's guerrilla tactics avant la lettre