Weight gain (or loss) is really a function of energy (calories or kilojoules) in and energy out. If the energy in exceeds energy out, weight will increase, as food is merely a form of energy for our bodies, in the same way that petrol is the energy source for a car. The fact that eating is pleasurable is a problem that mankind has yet to solve, leading to the present epidemic of obesity. If a person wishes to lose weight, they have to alter the equation by decreasing energy in (food), and/or increasing energy out (exercise).
There are a number of diseases that can affect this balance, but still do not alter the basic equation. Part of the energy output goes to maintaining the basic operations of the body, such as breathing, heartbeat, digestion etc. This is the metabolic rate, and this rate varies from one person to the next. If the metabolic rate is high, the person needs more energy (food) to maintain it, and is unlikely to gain weight. If the metabolic rate is low, the reverse is true. Diseases that slow the metabolic rate can therefore affect weight by reducing the energy (food) needs of the body.
Diseases that may cause weight gain include hypothyroidism (an under active thyroid gland in the neck), congestive cardiac failure (a damaged heart that slows down and is unable to beat effectively), Cushing syndrome (over production of steroids in the body, or taking large doses of cortisone) and the Prader-Willi syndrome (chromosomal defect).
Some medications may have weight gain and increased appetite as an unwanted side effect. Examples include steroids, tricyclic antidepressants (for depression) and thioridazine (used in psychiatry).