As with a lot of things in this movie, there is no clear answer. However, I can share my opinion.
Killing his own wife was an event so scarring and traumatic, that even through his condition, he couldn't just forget it ever happening. However, he also could never believe about himself that he had actually killed his wife. He wouldn't have been able to live with it, and his condition wouldn't let him remember. So his mind projected that event onto something that happened before he lost the ability to form new memories, meaning that he would still be able to remember it.
I'm sure this isn't the only answer, but this is what makes sense to me. The movie is dealing with trauma and the human brain here, so I'm not even quite sure if there's a definitive answer that's been researched/proven. You could do some research into trauma to see if Leonard's condition is even realistic in the first place. The movie probably took some creative liberties. I hope this helped.