All our habits are originally underpinned in what we call the Positive and Negative reinforcement. What is more commonly known as Trigger - Behavior - Reward, a simple formula that states by: Action + Reaction = Outcome. That's how we learn and establish habits. But the problem is that we forget that those early reactions are always based on a context dependent memory.
Suddenly, we start assuming that what makes me feel good in one situation, might also work in a completely different one. So we tend to extrapolate the behaviors to get the same reward, but the trigger might be different from the original functional one.
If initially we developed a functional habit, out of context, we might cross the line from learning to survive to kill ourselves with those habits.
It's pretty clear that trying to control those "impulses" doesn't work, it even made them worse. We are trying to use cognition to control our behaviour. But the Pre-frontal cortex, the part of