Exercise will not magically cure your mental health. I believe being active and not having a sedentary lifestyle is generally good for mental health but it's not going to necessarily cure depression or anxiety.
Especially if the depression/ anxiety has an external cause (job, living situation, money, relationship issues etc etc). Exercie may help manage it a bit but the only cure is to deal with the cause