Once burned, twice shy. Twenty times burned, Central Europe. Between Ottomans, Swedes, Napoleon, Hapsburgs, non-Nazi Germans, Nazi Germans, and Communists, Central Europe has the habit of being burned to the ground by most any marauder.
To discourage this cycle of destruction, medieval city planners turned to a new model: find a hill, build a castle on it, and keep your important stuff in the castle.
We prepare to storm the castle.
Aside from walls, which came standard, the particular defense mechanisms varied from castle to castle. In Cesky Krumlov, the royals filled the moat with bears. (Incidentally, I have an idea for a Revenant sequel.) In Prague, castle dwellers pushed people out of windows, an approach which led to the 1618 Defenestration of Prague, my new favorite historical event. In Salzburg, the castle had a giant mechanical organ which could blast only one chord and was presumably used to annoy invaders or summon Von Trapps.