Castles were to be defensible, but they could also be used as a base for attack.
One of the most common places for a castle was beside a river in order to guard the route against invaders from the sea. A shower of arrows from the castle would prevent most boats from getting past. The Tower of London is built in this kind of place.