"... but this margin is not large enough to contain it." Sound familiar?

Now, it's possible that Fermat thought he had a proof of his theorem, but that it would have turned out to be wrong. That happens sometimes. But he did not write it down on any document that has survived to this day, so we know that he had something that has been lost.

It's similar to history. We know that there are books, plays, etc. that used to exist, but that nobody knows today. Because other writings that have survived to this day quote from them. But beyond the quote, we don't know anything else about the play or the book or whatever.

Fermat's Last Theorem almost certainly isn't the only case of mathematical theories that we know were published somewhere but that we have no record of today. It's just the only one that I happen to know about, not being a mathematician myself. I'm sure there are some people on HN who know of others.