Habits are formed by a three step process which is also known as a loop.
Firstly there will be a trigger point; at this stage the brain will automatically chose which habit is deems appropriate. These triggers can be anything from places, times even people.
The next part is the routine. This may be anything physical, emotional or mental- such as eating, drinking and smoking.
Lastly there is the reward. This is what imprints itself on the brain and closes the loop in a satisfactory way or so the brain thinks. This is manifested by the feeling (or illusion) that alcohol, nicotine or biscuits are the reward.
As time goes on this loop will become more and more automatic and the cue and reward become so close that an overwhelming sense of anticipation will emerge.
For example the sight or smell of a cigarette is enough for the brain to crave nicotine. If the reward doesn't materialise then the craving will grow and grow until it is constantly at the forefront of the mind.
Most habits will never go. They become encoded in the structure of our brains. Opening a bottle of wine when the children have gone to bed or snacking on crisp mid-afternoon will remain as patterns inside our heads forever.
As far as the brain is concerned it doesn't matter if these habits are doing us damage or not. It cannot tell the difference. It is just a loop of behaviour that leads to a reward.
You can take control of the habit loop by forming a new neurological routine to replace the existing bad one. The bad habits are forced to the back of your mind.
When the bad habit has been replaced with a good one, studies show that the new one, for example having tea instead of wine or an apple instead of biscuits, will become as automatic as any previous habit was.