Some people suffer depression with no cause, and other suffer from depression because of their life - ie lack of employment, bad housing, bad relationship, pain, embarrassment at going out, etc.
If depression is due to perhaps the consequences of being overweight and housebound/not able to work/immobility, etc and weight loss improves those factors then the change in lifestyle may ease the depression.
I know people though who have it all - money, good jobs, holidays, lovely home, etc., and they are still on anti-depressants.