Forts were built by the rajas of the Mahajanapada because people were afraid of attacks from other kings and needed protection. It is also likely that some rulers wanted to show how rich and powerful.they were by building large, tall and impressive walls around their cities.Also in this way,the land and the people living inside the fortified area could be controlled more easily by the king.