Sin is like a foul-smelling swamp full of sewage; the more one sinks into it, the less he senses its smell, because he actually loses his sense of smell and can't tell that he is drowning anymore.
At the same time, anytime one makes a strong decision to return from this swamp, it is considered a victory. One who has decided to fight sin, needs to increase his ambitions for such, so that he can be victorious in the following stages of this struggle.
As for how to increase ambition and motivation, there are some methods that might be useful:
1- Paying attention to the disadvantages and harms of the sin
2- Paying attention to the high value of your own character
3- Paying attention to the magnanimous rank of Allah (swt) and that He has to be obeyed
4- Paying attention to the significance of struggling against sin and one’s illegitimate desires as a skill, and the pleasure of winning the struggle against the self.
In addition, you should try not to ever be alone anywhere and fill your free time with reading, sports, recitation and memorization of the Quran, worship, fasting, interacting with religious people, etc. This way, the chances of the sin being repeated will be less.
If you are single, try to get married as quick as possible, because fulfilling your sexual desires in a legitimate way might be the answer to the problem.
One of the most important points concerning this matter is for you not to lose hope in Allah’s (swt) mercy, and to trust in and ask Him for help. Don’t become hopeless just because you might sometimes return to the sin after you have repented from it; try to fight this problem using what was mentioned above. We believe that through the grace of Allah (swt), you will win this battle.