Your brain can replay the day while you sleep
During deep sleep, the hippocampus repeats patterns of activity linked to recent experiences while other parts of the brain help store them for the long term. Some of the work needed to remember something tomorrow therefore happens after the original experience is over.