The simple answer is that "it's complicated."
Depression often leads to a cycle where people will withdraw, which will cause them to become more depressed, which will lead to further withdrawal. The initial "treatment" for depression is to encourage patients to force themselves to engage in activities (particularly exercise or activities that involve social interaction) even when they don't feel like it. This helps break that cycle.
But that's depression, and it also isn't necessarily roleplaying as the activity. For some, roleplaying is mentally taxing (depression can slow your ability to make decisions). For some, roleplaying is emotional (depression can blunt your emotions). It might not be the best choice for a person who is depressed.
Grief and mourning (which need not be tied to death--could be a breakup, could be mourning the loss of a brother's sanity) are another matter. They are sometimes related to depression (can trigger depression, or can be more a more common response in someone already depressed), but not always. Sometimes people who are grieving need time alone, they need to come to terms with what they are grieving, and to move on. Taking time away to actually deal with the problem (for instance to think about it, what it means to your life, how you're going to move forward) even if crying and feeling sad during the process can be a very healthy way to resolve it.
Then there is stress. Stress can be caused by both negative events and positive ones. A person who is at capacity for stress might not feel they can handle a positive stressful event. They might need time to destress which can be in the form of a nap, a soothing bath, time reading, etc. I could imagine a person very excited about and enjoying the planning of their upcoming wedding, but also overwhelmed. For them, going to a gaming group, interacting, doing math, etc. might just put them over the top...and they might need a break where they can just shut down.
And, of course, there is the possibility of all three of these, as well as additional factors coming to play all at the same time.
But, more specifically, and personally...yeah, I usually would rather game when I'm bummed out than not game. But to each his own, and I don't know if I'd be as inclined to game if a major event had recently happened as if I just was feeling sad.
In response to rpgs being a great way to distract yourself, that's true for some. For others, they remain focused on their problem and are distracted from playing...and may find another activity a better distraction. Also, sometimes distraction is not the ideal way for a person to work through their emotions, as I've outlined above.
There ARE unhelpful and even harmful ways of dealing with emotions, and there are people who instinctively try to resolve things in ways that are not effective. However, unless you know what's really going on, and unless you know what is healthy and what isn't it's best not to judge, and sometimes not even helpful to give advice.
Often friends will give the exact opposite advice of a trained professional in an attempt to be helpful, because they are personally invested, because they don't know what is actually the most healthy way to resolve an issue, or because they don't fully understand the issue.