Except no. There is literally no disease or condition where "weight loss" is actually an appropriate, evidence-based intervention. There is no disease or condition where acquired nutritional deficiences, multiple, is an an appropriate, evidence-based intervention.
Weight loss as an intervention fails for virtually everyone. Weight loss surgeries not only carry a risk of side effects, including death, they aren't actually successful at keeping all that "excess" weight off. Even the American Society for Metabolic and Bariatric Surgery says most weight loss happens in the first two years, and weight regain is common by 5 years. They also say that most people don't actually lose all the weight that the doctors said they should.
If you think that two years and five years sounds familiar, you're right.
Additionally, all those things we are told that being fat causes? Like heart disease, joint pain, diabetes, etc.? For one, they happen to thin people too. For two, they don't automatically happen to all fat people. Not even the fattest person you can think of. We've all been led to believe there is a clear causal relationship between fatness and ill health - namely, that fatness causes ill health. There is no such clear and obvious causal link that has been found in research.
There may be a link, however, between WEIGHT CYCLING and ill health. Weight cycling is what happens when you are in that 95%+ of people who regain all the weight lost (plus usually a little more) within about five years. And then you diet again, and repeat the cycle. And again. And again. Like a lot of people do. THAT turns out to be a better explanation and causal factor than actual weight.
There's also a link between fat stigma and ill health - yeah, being shitty to fat people can and does negatively impact their health. Doctors refusing to run diagnostic tests amd instead attributing all health problems to someone's weight negatively impacts health.
You know what we do know usually improves people's health? Your basic ass "healthy lifestyle" stuff like engaging in comfortable, joyful movement every day. Having enough good food to eat. Having a good social life and social supports. Having things you think are fun and doing them. Being treated with the dignity you deserve just by being a human being. We have way, way better evidence for these things helping, regardless of a person's weight or health status, than we do for weight loss (which is frankly a low bar to clear, because we don't actually have any good evidence for weight loss, but nonetheless, basic shit like this goes soaring over it).
And you know what else we know works for joint pain? Addressing the actual issue, such as arthritis, injury, hypermobility, etc. Things like pain relief, physical therapy, setting the damn broken bone.
You know what we know works for diabetes? Addressing the actual issue, which is a fucking endocrine disorder that has a strong hereditary component and has to do with how your body makes or processes insulin. (And fun fact, there is growing evidence that Type 2 diabetes is also autoimmune in origin, and that COVID can trigger it.)
You know what works for sleep apnea? (And as an aside, it boggles me how many people think being fat is a one-way ticket to sleep apnea. Do you think there are gobs of fat just hanging around in people's noses and throats and lungs, impacting their breathing? Really?) Addressing the actual issue, like craniofacial structure, edema from other medical conditions, or issues with upper airway muscle function.
We actually have evidence-based treatments for heart disease, high cholesterol, joint pain, diabetes, sleep apnea, thyroid disease, high blood pressure, all the things we are told that being fat puts us at risk for (which, by the way, again, we don't actually have great causal evidence for that). Those evidence based treatments work for fat folks, too, every single day. Weight loss does not.
So yeah. It's shitty for doctors to tell people to lose weight before any other treatment. But it's shitty for them to tell people to lose weight during or after other treatment, too. Weight loss does not work, and it in and of itself can raise your risk for a lot of conditions.
Oh and by the way, the American Society for Metabolic and Bariatric Surgery still lists gastic banding as an approved surgery. They also list one that bypasses ⅔ to ¾ of the upper small intestine (hello nutritional deficiencies!!!), and one where a saline balloon is placed in the stomach.