I've found this phenomenon to occur quite often in my programming endeavors. What am I talking about? I'll explain. You're creating something, a program, it doesn't matter what. You notice a bug that renders your project unusable at times. After hours and hours of meticulously scrutinizing your code, stepping through with a debugger and littering output statements everywhere, you finally find the root cause and fix it. What caused the problem? Something incredibly stupid that you can't believe you even did in the first place. You want feel happy and relieved that you fixed the problem, but you don't know if that's an appropriate reaction given it was your own extreme stupidity that created the problem to begin with.
For the past few weeks I've been hunting down a bug in a game that I'm developing that would occasionally cause the program to hang, and knew of another bug that I would have to tackle after. I've spent hours upon hours trying to narrow down the cause of the problem, and just managed to find it today. In a seemingly unrelated piece of code I had to perform a task, and could do so either way A or B. I chose way A and left a comment saying "maybe way B would work better here." After changing to way B, both bugs have disappeared. I'm not sure how I'm supposed to feel about this, especially considering I left a note to myself on the very line causing both problems.
It is quite logical: each bug in your code could only be introduced by you. So you are ultimately responsible for any problems with your program. Be it either mistyping, forgetting to replace test code with proper implementation, not implementing something fully (for all cases), choosing subpar algorithms, etc.
You've just got to accept that you're human, and you're not going to be thinking 100% clearly 100% of the time. I've lost count of the number of times I've come in at the start of the day, and immediately started to rethink everything I was doing the previous day, and realised it was all wrong.