Most castles were initially built as fortifications, located on trade routes and along borders between countries. During the ancient Roman invasion of Europe, they had constructed fortifications in the same areas; these ruins were later frequently used as foundations for the new castles.
In medieval times, noblemen and kings at first built wooden structures to house their families, other nobles, and household guards on top of the mound, later called a motte.
During the 1000s, the Normans were the first to change castles to the motte-and-bailey defense system. The bailey was a walled courtyard, creating a line of defense and protecting the keep.
These castles were primarily fortifications that resembled forts rather than what we think of as castles today. They formed a good defense system against invaders and were effective against the weapons of the time. The earliest motte-and-bailey constructions could be erected quickly too if an attack was imminent.