Knowledge is a curious thing. Philosophers have argued for millenia over how metaphysical entities like memories can be contained within the physical confines of the human brain.
Today the answer to the question is known: they aren’t.
When a person experiences an event, their soul creates a memory somewhere in the realm of memory. Whenever they later recall the event, whether consciously or not, their mind metaphysically reaches out into the realm to find the closest memory that matches their description.
Every memory is a rough approximation of the event that spurred its creation, though it is often coloured by the opinions and emotions of the experiencer. Additionally, the act of recalling a memory alters it further, painting over it with the new emotions of the viewer. Even if gone unremembered, a memory is not perfect - every memory decays naturally over time, its endurance depending primarily on the significance of the event and the amount of times it was recalled.
A dreamer who exits their dream may stumble upon a gateway to the realm of memories, therein they can seek out specific memories to gain insight into the events of the past, present, and perhaps also the future.