Because writers, like you and I, have something I call 'CHARACTER EMPATHY'. When my real, non-imaginary life is going badly, I feel sad... depressed even. The same as everyone else.
However, when anyone of my thirty or more characters in any of my novels or short stories feel's sad or depressed, I can also, for them, fall into sadness or depression. Take my character Sophia, whose head I'm in most, she' a strong character but even she gets sad sometimes and that makes me sad.
My character Theo, whose wife was in a car accident, is also feeling down. From his POV I'm sad. In fact, because I live the exciting life of my books, happiness and satisfaction are rarely felt, hence the excitement part. My life is a constant climax of events.
SO A TIP: take time out from writing each day just to go to that happy place. Look at a happy picture. I buy Britain magazine and look through the wonderful hotel adverts. Ah, to be in the Cotswolds or the Peaks.Don't fall too deep into Character Empathy. Be happy. Think happy place.