> Why does doubting yourself, lacking confidence in yourself, make you a better a programmer?
I prefer to say it in a slightly different manner.
Ask yourself: could I have implemented this better? Better can imply more efficient, readable, in terms of design ...
Essentially realizing the fact that one might not have done a perfect (or even a reasonable) implementation and that it might be possible to improvise upon.
I've often found myself redoing pieces after thinking about the maintainability, readability aside from worrying about functional aspects.