On an incredibly simplistic level, you can think of depression as occurring when your cortex thinks an abstract thought and manages to convince the rest of the brain that this is as real as a physical stressor.
Robert M. SapolskySome Poor grad student pressing on the flanks of a hamster and out comes a doctorate on the other side
Robert M. SapolskyPulling a gun's trigger can be an appalling act. But if it is suicidal drawing fire to save someone, it has an utterly different meaning. Placing your hand on someone's arm can be an act of deep compassion or the first step of betrayal. The punch line? It's all about context, and the biology of context is vastly more complicated than the biology of the behavior itself.
Robert M. Sapolsky