Because wars and battles were common, knights, soldiers, and guards often lived on castle grounds. Many castles were placed on high ground so that soldiers could command a view of the countryside or on mountain passes to prevent invading troops from crossing.
Originally castles were built from wood, but they were too susceptible to fire. A single flaming arrow could turn the entire place to ashes. So castle owners began to build and rebuild castles with stone walls.