I will not do the concept full justice, I definitely suggest the books. Here's the short version. Most of what we do is just a habit loop. No decisions involved. Your brain receives a familiar input in terms of what you do, see, hear, smell, whatever. It pulls up the script it has for what to do in that scenario. It executes it. The execution is, to oversimplify, run by the part of the brain that we share with animals.
Willpower is attempting to refuse to act on the script. Again oversimplifying, the newly evolved distinct human part of the brain, the logic centers, is what chooses to not do what the animal brain says it's time to do. It works for a while, but research shows that willpower is a finite resource in the brain. You cannot fight forever.
So the simpler approach is to cut it all off at the source. Don't experience the trigger at all. How to Change discusses this in more detail, but I identified everything that triggers me to use, every scenario in which I tended to use shortly thereafter, and stopped those things instead.
I built morning and night routines full of healthy habits so that THOSE became the habit loop my mind mindlessly executes. I replaced all the old loops.
Now, you can't avoid 100% of triggers 100% of the time, sometimes they can come out of nowhere. This is where mindfulness plays a role, the ability to just let them roll over you and then move on. But I also established in my mind and wrote down a plan of action for what to do in those moments. Having an unequivocal plan in advance to execute helped also establish a new habit loop for when the urges do come. No questions, no debating, just execute the new plan.
Scientifically, the old loops will probably exist forever, ready to be used again, but the longer you go using a different loop, the more faded they become, the less powerful the urge to execute them becomes even when they are triggered. Which is where i am now. I still have little tinges of urge when I, for example, see an unexpectedly pornographic image somewhere. But I just execute my mindfulness to note that it's just my brain trying to execute an old loop, and move on.
We tend to think we use porn because we are horny, and it may have been true at the beginning, but now it's just a habit loop. Cut the loop.