This is actually an enormously complicated question, but maybe a simplistic answer will suffice.
Addiction (to anything) is all about mind, including the mind's ability/willingness to tolerate discomfort. (Change of any sort is perceived by the primitive functions of the brain as threatening - the acquisition of a longed-for new job measures as high for stress as does getting fired.) In evolutionary sequence, we're all hardwired to move toward survival and away from death, just like a plant that turns toward the sun; toward security and away from danger, toward pleasure and away from pain, and then toward the myriad forms of self-gratification and self-enhancement that this evolves into with the capacity for abstract thought, and away from anything perceived as a threat to the now quite complicated territory that we define as "me."
If you pay attention, an enormous amount of mental and physical energy every day is spent in myriad, often reflexive, adjustments toward what is perceived as positive and away from what is perceived as negative, from little bodily shifts to ease physical comfort to complex psychological and social gambits. It's what we do.
All of this is fine so long as there are no significant obstacles to getting what we want and keeping it, and avoiding what we don't want and keeping it away. That's optimal, or seems to be. Anger and/or depression develop, and all sorts of complicated mental suffering, when that fails, and we can't find a way to accommodate threatening feelings of helplessness by incorporating it into a new project for happiness.
This is where addiction comes in. Primitive mind confuses pleasure with survival (it just registers positive and negative) and abstract mind provides all sorts of tricky doublethink rationale (see "defense mechanisms", "delusion", etc) to hold onto an experience perceived as powerfully enhancing psychological, social and/or physical well-being.
But abstract language allows us to see contradiction as well. It's really easy to hook a rat on ......., and once hooked, they simply seek it blindly. Humans get all tangled in a huge variety of mental convolutions because an option is at once perceived as a threat and a haven of safety. We experience dilemma, and suffering ensues. The rest is painful mental gymnastics and efforts to have the cake and eat it too.
Resolution seems to happen when any one or combination of events occur. Sometimes the association around habitually turning to the perceived positive becomes increasingly dominated by negative associations (fear of death/illness, loss of social status and security, compromise of moral ideals, etc), and the mind decides to tolerate the discomfort of relinquishment as a lesser discomfort. (This involves the relinquishment of a whole set of incidental behaviors that have also become "addictions", some of them with their own rewards, in all spheres). Sometimes an option perceived as very rewarding appears that would be lost if the other isn't relinquished (a smoke-hating lover, the soul's salvation, whatever). Again, the mind becomes willing to tolerate discomfort. Depending upon the degree of rationale that the habit has been encrusted with (like, "I will become insane without ____", or "___ is an integral and valued part of my identity", etc.), suffering ensues, and is tolerated until the new "habit" of mind has provided adequate and predictably reliable reward ensues, or the project fails.
(This is why people take up old addictions again under stress - there's always that rather stupid primitive brain that gets activated then, and that says, "the feeling of safety generated by having a drink or binge eating or smoking or whatever will somehow protect you from the insecurity you experience by having just lost your job...").
Sometimes just the feeling of strength and self-mastery that extends into all spheres of life by the act of relinquishing a dangerous pleasure is a strong enough substitute. This is why ex-smokers are so ostentatiously obnoxious - they are reinforcing themselves.
Or one can substitute/compensate. Have you ever been to an AA meeting? Chain-smoking out the wazoo, and tons of other compulsions. Compulsion itself is a secondary addiction.
But finally, it's all in the mind - the same abstract mind that holds an addiction can work its way out of it. It can choose to minimalize the discomfort and maximize the satisfaction of quitting. It can abruptly disrupt the nagging and unproductive internal argument by refusing to engage in it (Like with a wheedling 2 year old - "no, and we're not going to discuss it. Would you like to color?") until that auxilliary mental habit dissipates. It can literally change the mental language associated with the habit, say "want" instead of "need", and all that, and deconstruct hyperbolic beliefs and assumptions that support the habit. The mind can change the mind.
Ecigs make people really happy for the simple reason that nicotine, though physically addictive, is not the aspect of smoking associated strongly with threat, being neither carcinogenic nor mutagenic. We enjoy it and are not so afraid of it. So we are suddenly, to various degrees, freed of the dilemma altogether, without even needing to relinquish harmless and pleasant peripheral attatchments like gestures and tactile experience. PILES of reward, socially, financially (eventually), and etc. If we want to quit nicotine, too, we can do so in a rather leisurely and much less stressful manner, by just lowering strength.
That's not bad, it's very, very good.
When my obese clients begin to stop talking about "cravings" and "triggers" and "resisting" and "being strong" and "struggling" and "denying themselves" and "hunger", or producing peons of anguish about being fat, usually alternating with defiant condemnations of various internal and external pressures that seem to ask them to change or reject "who they are", all of which refer to some aspect of unwanted feelings of helplessness to get what they really feel that they want and need, and start going on excitedly about the deliciousness of salmon and melons and couscous, that's when they start really losing weight.
Addiction is just wanting something so much that competing wants are outweighed. "Compulsion" is something of a lie.