Ultimately, true weight gain, which is an increase in body fat/adipose tissue as opposed to an increase in muscle mass or water retention, can only happen due to caloric over-consumption or eating too much. There is simply no other way to gain weight!
For instance, in the case of PCOD/PCOS, weight gain appears primarily due to:
- Lower metabolic rate that results in caloric over-consumption due to eating the same amounts as before. This results in increased weight gain. 
- Dysfunctional appetite management due to which those afflicted with the condition do not feel as satiated after a meal as those without the condition, causing overeating and therefore caloric over-consumption. 
- Increased resistance to insulin increases blood insulin levels  that cause additional blood glucose to be converted to and stored as body fat .
As you can clearly see, while the causes may be many, ultimately it boils down to how much we eat and therefore to a great extent, is in our hands. The first step in instances of medical issues is to make the derivation of pleasure from food an optional extra, rather than a compulsive requirement at every meal.
- Insulin Resistance and the Polycystic Ovary Syndrome Revisited: An Update on Mechanisms and Implications
- Genetic, hormonal and metabolic aspects of PCOS: an update
- Association of leptin and insulin resistance in PCOS: A case-controlled study