I think that just doing keto for a few months can change the way you think about eating, or even change your relationship to food overall. That more mindful approach to nutrition might last longer than the temporary deprivation. It would explain some of the longer-term benefits that people who've [successfully] done keto tend to talk about.
This keeps being touted again and again as if it's some grand criticism of diets. Obviously if you stop following a diet, its results will stop applying to you. If you follow a diet that restricts your calories and causes you to lose weight, and you then stop following the diet and eat whatever you ate earlier, of course you will gain back your weight.
Healthy eating is a lifestyle decision and a lifestyle change. You have to understand what your diet was trying to achieve, and then try to apply similar concepts to your general everyday life.
And, once you adopt it as a lifestyle, you really watch what you eat even after the intensive diet - I eat whatever I want, I just don't find myself wanting sugary foods because I know what they do to you, and I have zero problem staying at my desired weight.
The point is, those people are, in practice, a tiny fraction of dieters.
Diets work (or not) based on fairly straightforward causal chains. People who want to continue to do exactly or very nearly the same of whatever they were doing and see a drastic change are bound to be disappointed not only in the mission of reducing weight but also in life.
It's interesting how there used to be so much variance in the world (and in fact, you can turn on the TV or get on a plane and still see variance everywhere you go).....yet if you were to take the word of people on the internet, everything is identical everywhere.