I don’t think there is a consensus on the topic as to why it happens, the consensus seems only to be that it does happen. Some have suggested it’s due to an interaction between the subconscious and superconscious mind, some say its about cleansing the subconscious and so on. If you start looking into it, say, googling vipassana (which Google which translate as meditation) and random memory recall, you’ll find entries like this:

and this:

You’ll also find the usual suspects trying to create disinformation about the topic, like this:

Ignore such usual suspects, and focus on what is. This is a thinly veiled attempt to demonise the process of self-integration and mindfulness, because non mindful action and confusion is preferential to the control structures.
You’ll find the same formula over and over again: body awareness or mindfulness/meditation, and then random memory recall (usually in my experience very true memories, and never false ones, and possibly triggered by physical sensations or smells). One analogy I could give would be something like stirring a put of stew and seeing different things come to the surface from beneath the water.
Remember that people who have had NDE’s often speak of seeing their entire life in a kind of immersive cinematic experience, and its so common that we have this phrase “I saw my whole life flash before my eyes” that we use of any dangerous situation. The descriptions of these experiences, as well as the experiences of recalling early childhood memories tells us that our entire life is recorded somewhere within the self-hologram ready for access. Bohm would no doubt say that this is a result of the implicate order unfolding from within us into the explicate one, or vice versa.
Hollywood knows these sorts of things too, just think about Lucy’s monologue to her mother on the phone while she’s being operated on (in the movie of the same name about a woman whose accidental exposure to a drug leads to her gradually increasing her brain usage to 100%), or the scene with the neighbour in Limitless. Except in Hollywood its always about a drug doing it - take this pill or smoke this, don’t put any effort in and you can become superhuman.
In reality, we are carrying all this crap around inside of us, every day of our lives, and it needs to be organized and its importance reclassified or lessened by our mind, re-recorded so that we can use our own minds / holographic self image more efficiently. And as we refine the faculty of attention/awareness, like people learn to do in martial arts, very interesting things start to happen.
That’s why I got so excited on my journal in the later entries about all this stuff I’m studying, because through intentionality, through mindfulness, which leads Chi in our bodies, we can start to see a link between the science of what William Maxwell and Robert Fludd thought of as “spirit”, what Eastern folk call chi, and the holographic theory.
I’m still in the dark as to why memory X shows up rather than memory Y, and what the stimulation threshold of awareness/intention times duration is, but as long as you understand the general principle and know to observe the memory without emotionally reacting to it, it won’t seem so troubling, and you can understand it as part of the normal process of self-integration.