This is something I relate to a lot. I've been paralyzed many times by being unsure if I'm coding the Best way. In the last 5 or so years I write some awful code but every piece of terrible code taught me how to write good code. The bad code worked, it did what it was supposed to do but it ended up causing complexity and making it hard to add on to down the line and that is what helped me learn to things right.
It has nothing to do with bad code not working. I think its when bad code works that you learn. You should have seen my pet project when it was started in 2011 (which I'll shamelessly plug, https://writeapp.me). It was a series of scripts all string together. Then it was rewritten using a framework when the first version couldn't be extended. From there the models, views, and controllers have been refactored many times over each time making the app more extensible, less buggy, and from a code perspective, more "right".
It's a one step backward, two steps forward kind of situation. Each time you hit a wall you go back and not only fix one problem but move forward helping yourself avoid other common pitfalls.