The best piece of productivity advice I ever received was that when you are procrastinating it is very frequently (not always, but frequently) because the thing you are avoiding is a thing you are afraid you will do poorly.
Knowing this, whenever I find my attention wandering, I ask “Am I not doing this because I’m afraid the results will be unsatisfactory?”. When the answer to that question is “yes” I work on figuring out why that is and then work to address that problem. As it turns out, attempting to solve that problem always stops me from procrastinating.
Changing focus is very helpful.