You will always make mistakes. This is one of the few genuinely inevitable and immutable truisms of life, and its application to software development does not meaningfully differ from its presence anywhere else.
The corollary of this truism, however, is the necessity of going back and fixing the mistakes that you have made.
Do not let mistakes become technical debt just because the next new feature is more interesting than fixing an old bug. You have no way of knowing when upcoming features or future changes in user needs or behavior might turn that minor bug into a show-stopping disaster, and by the time that happens, you may have forgotten it exists — or at very least, lost the half-formed solution that had begun to come together in your head when you first saw it.
This is also another strong argument for good documentation, including documentation of things that are not working correctly. Just because a bug is not a showstopper that has to be fixed immediately does not mean that you can afford to forget about it, and if you do not make a note of it being a bug, it is very easy to train yourself into a workflow that works around it, blinding you to the effects that it may have on your users. And over time, these little issues that you can easily internalize a workaround for start to build up, until the product may as well not work at all for a new user.
Make sure you are always setting aside time to go back and fix mistakes. The traditional adage — that if you do not schedule time for maintenance, it will schedule itself — definitely holds, but this goes deeper than that. Many mistakes will never lead to downtime or the sort of bug that actually makes your boss think spending time on fixing a bug is worthwhile, but nevertheless detract from the quality of the project as a whole: bad UI design, pages that are clumsy to use but still technically get the job done and are technically accessible, spqghetti code that takes longer and longer to fix every time, you name it.
We, as an industry, have developed a high tolerance for this sort of thing over the past couple of decades. But things do not have to be like this, and this itself is a cultural mistake that we can and must fix.