Question: how does elena lose her memory?
Answer: After a number of failed attempts, Elena confessed the truth: that she had fallen in love with Damon while technically still with Stefan. Erasing this moment of realization from Elena's memory had a domino effect of removing every good memory she had of Damon.