I don't believe that people can gain weight while eating almost nothing, but I believe that their internal distribution of energy may be out of whack.
Proponents of naive thermodynamics model tend to assume that only "excessive" energy is stored into bodily fat, once all the other tissues have had their fair share.
That is not really true in insulin resistant people, whose storage may be excessive and leave the rest of the body unsatisfied and hungry, which drives them to eat more than a healthy person would.
To us, this looks like deliberate overeating, to them, it is a result of constant hunger caused by the fact that some part of the energy consumed is being immediately locked away in fat tissues by dysregulated metabolic processes.
Notably, it isn't easy to "correct" this situation by just eating less, because that will leave those people feeling really starved. Insulin sensitivity must be restored first, then the fat stores will give up their excess willingly and that person won't suffer.