From a recent article in Fast Company, although I’ve read similar views elsewhere:
But that cost to accuracy is the price of admission to your long-term memory. When you recall a memory, it feels as though you’re just summoning it up wholesale, but in reality your mind is reassembling disparate bits of information from various locations in your brain, using its schemas as assembly instructions to build something coherent. So maybe you combine details of two totally different events or remember something that didn’t happen at all.
It’s worth remembering this when you’re obsessing over mistakes or unfortunate events (situations you perceive you could have handled better, often with the benefit of hindsight). They may not have happened as you imagined them anyway, even if the emotional debris remains!