Are there medical conditions that prevent people from losing weight?

Cushings syndrome. Any medical condition like cushings where body tries to store weight in midline, any disease that requires steroid intake like advanced copd, chronic inflammatory disease process that requires steroids to suppress inflammation all can cause weight gain.
Yes. The best known is hypothyroidism. Many people have suboptimal thyroid function and their doctors tell them they are ok. The reason is that thyroid screening test usually involves TSH and T4 only, yet what really should be tested is freet3 level in the blood. If your TSH is not below 2.0 you may be hypothyroid. Also low basal body temperature suggests hypothyroidism-test yourself.