European castles were primarily built between the 9th and 15th centuries as defensive strongholds and administrative centers for the nobility. Following the collapse of the Carolingian Empire, the decentralization of power led to a period where individual lords and princes needed a secure base to protect their territory from raids by Vikings, Magyars, and rival lords. A castle served as a physical manifestation of a lord's power, allowing him to dominate the surrounding landscape and pacify the local population. Beyond military defense, castles were the heart of local government, serving as courts of justice, treasuries, and places to collect taxes or tolls at strategic river crossings. They also provided a secure home for the aristocratic family and a barracks for their knights. Early "motte-and-bailey" designs (earth mounds and wooden fences) eventually evolved into the iconic stone fortresses with high walls and moats as siege technology advanced. Ultimately, a castle was a multifunctional machine designed for survival, social control, and the projection of authority in a fragmented and often violent feudal society.