Joseph saved the food in Egypt during those seven years and stored the food in the cities. In every city he stored grain that grew in the fields around the city.
The only land Joseph didn’t buy was the land that the priests owned. The priests didn’t need to sell their land because Pharaoh paid them for their work. So they used this money to buy food to eat.