It's impossible to avoid failure. it's impossible not to make mistakes. As they say, only dead people can avoid making mistakes. Failure in life is as inevitable as your death.
If you meet someone who says they have never failed in their life then they are either lying or they have never tried anything new. As a Harry Potter Author JK Rowling once said
"It is impossible to live without failing at something unless you live so cautiously that you might as well not have lived at all – in which case, you fail by default."
So What do we Do?
It's simple, fail and make mistakes because thats how you will learn. We only fail once we stop trying.
The difference between a Genius and an average human is that the Genius never makes the same mistake twice. What a wise man does in the beginning a fool does in the end. As Albert Einstein Once said
"The definition of insanity is doing the same thing over and over and expecting different results."
Failure forces us to change, it crushes our ego and it makes us more humble. As Winston Churchill once said
"To improve is to change; to be perfect is to change often"
In the end, Success is nothing but your ability to tolerate failure.