Yes, we should all avoid making mistakes, but sometimes they just happen. Maybe we were not prepared for what could happen, we had not thought things properly over, maybe something unforeseen happened, maybe what we did create an unforeseen incident, maybe we created new knowledge, new insight.
Some mistakes are good mistakes, and are part of learning and developing. The important issue is that we need to learn from our mistakes and even more important that we need to learn to deal with the emotional consequences of the mistakes we make.
The following article gives some insight and advise regarding that: