Many of us make mistakes on endless repeat – but new insights can help us to learn valuable lessons from our failures.