Wikipedia
Encastellation (sometimes castellation, which can also mean crenellation) is the process whereby the feudal kingdoms of Europe became dotted with castles, from which local lords could dominate the countryside of their fiefs and their neighbours', and from which kings could command even the far-off corners of their realms. The ubiquity of the castle is iconic of the Middle Ages.
The process was rather quick once the castle, as a distinct type of fortress, was introduced. However, it took different forms in different lands. The methods and reasons of encastellation differed based on law (who could legally build a castle), necessity (who needed a castle), and geography (where could castles be effectively built). The stone castle originated probably in the north of France in the tenth century. Older wooden castles, of the motte-and-bailey variety are probably older, though they were far more common until well into the twelfth century.