Joseph collected all the food grown in Egypt during those seven years and put this food in the cities. In each city he put the food from the fields around it.
But he didn’t buy the priests’ land because the priests received an income from Pharaoh, and they lived on that income. That’s why they didn’t sell their land.