Actually, it is probably a mistake to focus too closely on only one thing. Perhaps, though is that you just wander a bit more than you should. But focusing on one thing doesn't work for most human activities or you get "blind sided" by other things. One needs "peripheral vision" in research as well as in driving a car. Other ideas relate to the main thread of your research and you need to be aware of these if you are to avoid a "too narrow" perspective and didactic work.
But, it is possible to defer work on those other ideas that occur to you as you go. My personal method, nowadays, is to keep a pack of index cards on my desk and when other ideas come to me that are not related to the task at hand, I write a quick note on the card and return to work. I keep these cards together and can return to them whenever I want a "working break". I can add a few thoughts to a card.
As a grad student, I wrote up "interesting ideas that might be pursued" on individual pages and kept these in a notebook. When I finished my degree I had a pile of potential work to be explored.
Note that the mind doesn't work especially efficiently if you try to focus it too closely for too long. You can get stuck in what seems to be (and may actually be) a dead end. It is good to give your mind a break. Sleep is useful for this, but so is changing gears. The trick is to organize your work in such a way that you let this happen without wandering down side alleys for too long.
Having the "interesting ideas" captured so that they can be returned to later may be enough to let you avoid following those threads too far at this instant so that you can return to the main thread.