This is very common. For me it used to be food (still is sometimes when I lose control) when my head hurt from worrying. I would calm down and just plain like having food, especially sugary and fatty ones.
Food/alcohol/drugs/sex or masturbation produce feel good chemicals in our brains like endorphins and serotonin, which makes us go for them when we are depressed. But what happens is, since these things feel so good, we get addicted to them and start going for them even when we aren't that depressed!
Moreover, these things in huge amounts are destructive. So when we are addicted to them, we start destroying ourselves. The way out is to bring about feelings of happiness from constructive, everyday work. So that you don't take more and more of these substances to feel happy which will end up destroying you.