"Châteaux" are homes for landed nobility. Early on, they served as strongholds for a nobleman to control and protect his land holdings. Later, as the threat of banditry reduced, they became country homes. There are many chateaus because any large noble estate would have one, and France has a lot of nobility and a lot of farmland.
Then when the French Revolution came along, and France dissolved it's nobility. While land redistribution wasn't forced in the same way that the Communists would later liquidate Russian nobility, the special rights that made noble estates more profitable were revoked. Estates were often broken up and sold to cover for various expenses, like maintenance of Chateaus. Without the concentration of land in large estates, there was no longer the countryside wealth concentration to maintain the large homes on them. As France industrialized, the concentration of wealth also moved from agriculture in the countryside to industrial cities, further reducing the function of large countryside homes.