I've sometimes wondered about this. To me, it seems like a "chicken & the egg" sort of thing. Did the experiences I've had (thwarted hopes, dreams, goals, etc.) cause me to become depressed or were the failures I experienced the result of me battling a mental illness that went unacknowledged as far back as childhood & remains largely undiagnosed to this day? Obviously I don't know the answer to that. (I wish I did.)
So how does one break free of this conundrum? I don't know the answer to that either. (And in my case I'm really too old for it to make much difference either.) But I've sometimes thought that, perhaps, one has to find something (a hobby, a job, a cause, etc.) one loves strongly enough that, if one pursues it passionately, it can overcome one's depression. But then, if one is so depressed one can't even think of anything one could feel passionately about, then we're right back where we began. So I don't know. I suppose that's what makes it a conundrum...