Task management and planning are critical skills for a programmer.
Learn to Learn
I love to learn. It's probably the most exciting part of programming for me, when I get to learn a new language or way to do something. Learning is fun, it's often something new, and it's also a recursive action.
Often beginning one topic will lead to another and then another and before you know it, not only did you need to learn Webpack, but also ES5, 6, 27, along with completely rethink the entire way you structure a website because apparently html is now outdated.
Really though, this is the point of this post, that beginning one thing will often lead to another and that it's difficult to 1) stay on target and 2) accurately predict the amount of time it will take. Point 2 is probably most important in a lot of business situations.
I try to keep a mental stack of where I'm at in a project. Sometimes I'll write it down, but often it's all in-twined with the process itself, so I find myself asking "why am I doing this?" to remember what the previous point in the project is and how everything relates to what I'm really wanting to accomplish.
Often times it's necessary to abandon one path, at least temporarily, to satisfy the original endeavor.
It's difficult to plan for what you don't yet know, however I've found that drawing box outlines (visual containers) really help bring ideas into focus.
Find the hurdles to leap so you'll know when you're past them and ready for the next.