Can definitely relate to this, particularly when I'm working on feature x but it looks like feature y is almost certainly going to be required at some point.
It just seems so much easier to include the ground work for feature y while writing feature x. Then by the time it's clear how much extra time it will take to debug and test those bits of groundwork, it's too late to return to a focussed implementation of feature x.