As with many other things, the first step to changing this, is to set the intention of becoming aware every time my focus starts to drift and consciously bringing it back to what's in front of me every time that it does. I believe that if I persist, I will become aware more and more often. This has worked when it comes to my job. And it works with many other things.
What I've realized, is that at my job I’m pretty focused on what’s in front of me and do things very efficiently. But when I sit down with projects at home, I tend to lose focus easily and become distracted. And I’ve realized that this is actually a habit. I’ve allowed my work that I do in my spare time to become sloppy and unfocused.
This also goes beyond mere lack of efficiency. When I do things in this manner, I also much more seldom get into a flow state. This means that I more often do things from a place of ego and of trying to force things, which means that I get access to much fewer novel ideas than I could.