This happens when you build structures in your mind that are designed to pin yourself in. From your wording, you are setting yourself up so that you either must solve the problem, or undefinable bad things will happen to you.
If you think about it, few tasks we take on do not allow you to walk away (unless you work for the CIA or the military). It might hurt a little, but we can walk away. However, we have learned persistence. We have learned that our mind is stronger than we give it credit; it just needs a little pressure. So we artificially make the problem seem more pressing than it truly is, unlocking access to the strength of our mind we usually hold in reserve.
However, along the way, your artificially high value on the problem means you have an artificially high willingness to trade for the problem. You eventually give something away you care about (such as forgetting to interact with your family while you furiously work at the task). Now your Self is hurting in a way that matters. The solution is to quickly begin escalating through your bag of tricks, hoping to find something to free you from this task so that you can recover that which you gave away.
I believe this is what generates this worry. It doesn't matter that you solved the last problem, because it isn't the problem that is causing you the pain. What is causing you pain is that you chose to give up more than you rationally should have, and you know that you'll do it all again because you don't understand why you did it in the first place!
Everybody faces this eventually... and I have a sneaking suspicion everybody faces it every day of their lives in varying degrees. The first step to stopping this spiral is what you've done: recognize there's a repeatable behavior here. If you want to stop it, the solution is to learn the art of letting go of that which is not truly important to you. There are dozens, if not hundreds of disciplines that teach this. Choose any one which fits with your personality.