When you get experience from your mistakes, one way or another, you learn how to get better in future situations, this is learning, but if you dont want to make mistakes, you can learn from others and analyze your knowledge.
In case of failure, I prefer to analyze my act and understand what I did wrong. This is necessary in order to prevent similar mistakes in the future.