the rulers of mahajanapadas introduced taxation because they wanted to build forts and buildings in order to protect their people. They didn't have enough money to do so.
That is the reason why they started collecting taxes as they were not able to continue with their work with the money they got as gifts.