Is it possible to buy a castle?
Yes, very much so. In fact, often castles are quite cheap to buy. But on the downside, you often need to commit to maintaining it, and that is a very costly affair. Not only will you be spending a lot of money on the roof, walls and other building elements, but also a small fortune keeping the castle warm and dry.
On top of that, if the castle falls under the historical French monuments (and most do), any changes to the castle will ned to be approved by the authorities, a long journey.
There is a good reason only the very wealthy built castles.