From what I understand, he was already dead from being hit by a train at the beginning (this is canon).
Fast forward, she starts conducting medical research at her father's workplace, where she successfully develops a "Recollection Drug" that allows her to "go back to the past" through dreams in which he is still alive. The loops in Chapter 1 begin when he, in her dream, starts to gain consciousness that his world always rewinds after certain events (that is because she's wakes up lol). The cycle resets again every time she takes the recollection drug. In essence, she has consumed this drug hundreds or even thousands of times, to the point where he, in the dream, starts to gain her memories (the dream owner's memories).
That's why the mc told her to stop and start forgetting him. Because the recollection drug is essentially her coping mechanism for her loss. (sorry if it's hard to read. my English is bad)