Joseph collected all the extra food produced in those seven years in Egypt. He stored it in the cities. In each city he stored up the food grown in the fields around it.
So Joseph bought all the land in Egypt for Pharaoh. All the people of Egypt sold their fields. They did that because there wasn’t enough food anywhere. So the land became Pharaoh’s.
But Joseph didn’t buy the land that belonged to the priests. They received a regular share of food from Pharaoh. They had enough food from what Pharaoh gave them. That’s why they didn’t have to sell their land.