The issue of obesity isn't all that simple. Many facets.
Let's get the genetic component out of the way first. Everyone's metabolism is different for a variety of reasons. Some people lack certain enzymes and can't metabolise certain nutrients, for example. Metabolism is also affected by your gut biome, that is the bacteria inside you. These help you digest foods and thus metabolise nutrients. Imbalances in bacteria can lead to obesity in some cases.
There are other organ-related metabolic disadvantages that some people have as well.
That being said, metabolism can be influenced by individuals. The above-mentioned bacteria are one example.
Other examples include exercise, CNS stimulants, diet, sleep and circadian rhythm.
It gets quite complex.
Not sleeping enough, for example, can mess with your diet and metabolism.
So can eating the wrong things at the wrong time of day.
Or intaking more energy than you expend.
Or what kind of energy you're intaking and what sort of activity you're then expending it doing.
It's far from simple.
That being said, for most people, a good starting point to maintaining good body weight is to take care of your gut biome and to intake only as much energy as you need.
To attain ideal body weight, it's less energy than you expend.
And to gain body weight it's more energy than you expend, but of a certain kind coupled with exercise.
It's complex.
Ooooh, then we could get into the psychology behind it all as well. And the way that certain diets induce changes in the brain (the brain is a beautiful, beautiful thing) that make it harder for people to change their behaviour in terms of diet.