Behaviors you want to change need to be understood and addressed in the context of their past, present, and future.
Each incidence of a behavior you don’t like has a past cause. Something led to that behavior, and you won’t be able to change that behavior by maintaining the same causal chain and then hoping to make a sudden swerve at the last minute. If every time you go into the casino you gamble away your paycheck, then you need to not go into the casino in the first place. Of course, going into the casino is a behavior too – so what leads to it? Go back as far as you need to in order to find a behavior you’re strong enough to change.
In the present, you need an emergency triage system. Something more severe – something to realign your mind if you’ve slipped. A replacement behavior. This is why “sponsors” are effective for people struggling with addiction: Calling a trusted person is a good replacement behavior.
And you need to be able to recognize the future for what it is – a series of effects of the choices you make now. Bad decisions are often coupled with short-sightedness; you behave badly now because you aren’t clear about where your actions are leading. If you can’t see the consequences in the long term, it’s easier to choose poorly today.
When you look at all of these things in one great causal chain, it becomes easier to begin to alter its trajectory.