I really noticed this a few years ago to the point that I changed a few things and they have helped.
1. I notice the movement of my attention. I used to default to something like: sit down at my computer to look something up. But before I do that, just check the email. Then I am down some sort of rabbit hole. I did this sort of thing with no awareness or conscious choice. The change is that I notice what I'm doing. Then I can rein it back. I make a choice. (I think scrolling videos gets us into a habit of not choosing what to pay attention to.)
2. Be aware of my curiosity. Try to stay in touch with it. If I get into the space of curiosity I have a lot more juice for sustained attention. Something that helps with this is long form reading, especially fiction (!). I find myself replenished for all my work. The next thing I will try is some group support: silent reading groups where you read together.
3. I have an app on my devices that limits my access to twitter and reddit etc to small windows in the day.
4. Turn off ALL notifications except text messages.