We associate this process with some sort of "will" or "willpower", though what these really mean is not that obvious.
The difficulty thus lies in delaying gratification.
But the most immediate cause of any of our actions can be traced back to our brain activity.
Some specific cues found in our environment hint to a potential reward and dopamine starts to raise anticipation. So dopamine is the one responsible to make us take action towards a specific goal.
To change a habit, both we and the environment have to change, and that's why self-discipline is so hard.
An individual can be changed through education.
We have so little control over the biology that determines our desires. But the part of our biology that is more malleable is our brain.
By acknowledging this, we can start finding alternative opportunities for learning and for satisfying our needs.