SPOILER: Highlight text to read: Question: Isn’t the whole memory loss/vanishing data plot device randomly implemented?
Not at all. Here’s how I think it worked/works.
We know the characters are sort of muddy on some details when they return to their bodies. However, Taki remembers Mitsuha, and Mitsuha remembers Taki, and all is well. Until, that is, Taki (in Mitsuha’s body) goes to go-shintai and the underworld.
Remember what oba-chan said: to return to the real world, you must leave your most precious item behind. This would have been the kuchikamizake for Mitsuha and Yotsuha – but that wasn’t Mitsuha, that was Taki. His most precious item at that moment was the whole swapping thing with Mitsuha and all the associated memories. Once he leaves go-shintai, he and Mitsuha never randomly swap again.
Note what happens when oba-chan “wakes” Taki up after the trip: he sits upright, and tears begin to flow. Taki’s mind hasn’t grasped it yet, but his connection to Mitsuha has been severed. His soul knows it, though, and he cries.
At virtually the “same” moment, Mitsuha is fixing her hair in the mirror when the tears come unbidden. “Why?” she asks herself. Mitsuha’s mind hasn’t grasped it yet, either, but her link to Taki is gone. Her soul recognizes it, and she weeps without understanding.
This, I suspect, shakes Mitsuha to the core. Maybe, she thinks, the date with Okudera has caused damage to her relationship with Taki. Uncharacteristically, she tells Yotsuha that she’s going to Tokyo, skips school, and gets on the train. The rest his history.
Now, here’s the thing: Taki’s kumihimo (braided cord) keeps his memory of Mitsuha alive. So he doesn’t start forgetting about her in earnest until…
I’m pausing for a moment here because this is where things get into some speculation. Remember when Mitsuha is talking with Teshi and Sayaka after her first swap? Teshi mentions her mind being joined with the Everett Multiverse. This is a concept associated with the Many Worlds Interpretation of Quantum Mechanics.
When Taki views the destroyed town that was once Itomori, he comes upon a Schroedinger’s Cat moment: he looks in the box and sees a dead cat, he looks at the horizon and sees a dead village. The waveform that was Mitsuha is now unquestionably dead and incapable of making entries in his diaries. It is a self-resolving paradox. Mitsuha’s entries disappear before his eyes. “If quantum mechanics hasn’t profoundly shocked you, you haven’t understood it yet,” says Niels Bohr.
At that moment, Taki begins to forget details, including Mitsuha’s name and existence. By the time they are back in the hotel, Taki can’t remember much of anything, including who gave him the kumihimo. But he will remember enough of his trip to go-shintai, and the kumihimo will encourage him to take action.
However, on the lip of the caldera, Taki gives the kumihimo back to Mitsuha. When she vanishes, his memory wipe is almost complete.
And Mitsuha’s memories? You notice she doesn’t begin to forget about Taki until after their meeting at kataware-doki. But why does she forget? For the same reason Taki did – Mitsuha emerges from the underworld (in Taki’s body), and in so doing will give up what is most precious to her – the memories and body-swap with Taki. It doesn’t take effect immediately (how could it? She’s in Taki’s body!), but shortly after she makes her way to Itomori, she can’t recall Taki’s name either.