James Clear is the authority when it comes to the science of habits. His book Atomic Habits is a fabulous read, but if you want a condensed version you can read his blog post: How To Start New Habits That Actually Stick.
The forming and breaking of habits is all about the feedback loop – cue, craving, response, reward.
When you want to make a good habit, make it obvious (cue), make it attractive (craving), make it easy (response) and make it satisfying (reward).
When you want to break a habit, invert the process – make it invisible (cue), make it unattractive (craving), make it difficult (response) and make it unsatisfying (reward).