What is the best way to stop making the same mistakes and to learn from experience?

Never focus on what you did wrong, but on how to change it. Analyse the problem and what actions you can take to fix it when it comes up again – make sure your solution is an "I should/will," not an "I shouldn't/won't" (e.g. "I will write down my tasks immediately so I dont forget again" instead of "I will not be lazy about recording tasks").