I wonder if a source of my distraction is thinking I can context switch while waiting for something to finish, like a build or a deploy. What actually happens is that I focus on the new task, and completely forget to monitor the thing that needs to finish. This wouldn’t be a problem if it were just me, but more often than not, I need to notify a coworker that the build is ready, so they can test it. I eventually remember to do this, but it’s usually after a longer delay than it would’ve been if I had just waited. And it means my focus is pulled from the new task, resulting in another context switch.
It might be worth trying to avoid context switching altogether, and just wait for things to finish. It does mean more time sitting around monitoring things, but I wonder if it would be faster in the long run.