Based on my reading, weight gain, as in resetting your maintenance set-point, which is what it sounds like you are describing, is a very well-known side-effect of the serotonin selective reuptake inhibitors (SSRI). In some cases, patients may even discontinue the medication. As far as I know, the underlying physiology behind this specific example is not well-understood.
In recent years, the use of next-generation sequencing (NGS) of DNA has been used to characterize the so-called microbiome in the gut of individual humans (sequencing faeces). Some studies have reported that thin, or skinny people have somewhat different microbiomes than fat, or obese people, leading to the hypothesis that some overweight people might have bacteria that are more efficient at breaking down their food such that more of the calories are available for absorption. Some evidence supporting this interpretation comes from experiments with fecal transplants.
If a medication also affects a patient’s microbiome (in addition to the drug’s intended therapeutic effects) then that could be another, less obvious(?) mechanism for weight changes.