Both, and more. Genetic first because we are all genetically programmed to store, in case a famine puts our lives at risk. Linked to what we eat obviously, because we eat either too much, or badly, or both. But also linked to our emotional state (the stress chronic usually makes you fat), lack of sleep (to sleep less than 7 hours per night exposes three times more to overweight), to certain drugs (psychotropic drugs, pill, certain antidiabetic or heart treatments …). Remember that even if genetically in the family, you are round, bad eating habits are also transmitted … And you can always limit the genetic impact through your lifestyle choices.
And even if there is a genetic ground … Don’t eat to relax!
We sometimes use our food as a food security blanket. They are then fatty and sweet, components that trigger anti-stress hormones. Replace them with a blanket activity: reading, swimming, drawing, sculpting, classifying stamps, running a blog, writing a diary … It doesn’t matter, as long as this activity relaxes you and monopolizes your attention.