According to a study published this year, the answer is as simple as it is impossible to control: genetics. After studying the genome of 1600 thin, 2000 overweight and 10,400 normal weight people, scientists confirmed that both obesity and thinness are hereditary.
These results may not be very encouraging for some people, but the good news is that this is a percentage of probability, not absolute terms. While it is true that some people will be more likely to gain or lose weight than others, this does not mean that it is an inescapable destination.
Obesity seems to have a heritability of 32%, while thinness is inherited by 28%. That is, whether you have genetic factors that promote weight gain or not, the end result will depend more on your own diet and care than on hereditary factors. Good news after all!