In the short term, stress does not cause depression. Stress activates the fight-or-flight system, motivating people to try harder and, hopefully, overcome the problem. It does this by raising stress hormones like cortisol and epinephrine.
When stress goes on too long it can turn into depression. This happens when people are faced with problems they can’t solve or walk away from. After a few months, that causes changes in the brain that look just like depression.
From that viewpoint, depression may serve a function, helping people conserve energy by giving up on losing battles. Unfortunately, the brain is not very precise, and true depression makes people give up on everything.
During therapy for depression, people learn how to solve difficult problems, move on towards more workable goals, or, in times of crisis, carve out some relief amidst an unworkable situation.