Some people have reported seeing their life flash before their eyes during a near-death experience. One person, Tony Kofi, said this of their experience:
“In my mind’s eye, I saw many, many things: children that I hadn’t even had yet, friends that I had never seen but are now my friends. The thing that really stuck in my mind was playing an instrument." He went on to become a successful saxophone player.
One theory is that our minds are constantly "reviewing" our lives and that we're only made conscious of it during a near-death experience.
Another theory says that our memories will unravel in terms of "cortical disinhibition" which is a process the brain takes on during a stressful situation. If anything, it's a coping mechanism the brain takes on in order to protect the psyche.
For others, Einstein's theory of relativity comes into play. Time doesn't "exist" and we live in a static block universe. That means that these memories of the time are always accessible one way or another. All in all, the brain is a complex organ that's not easily understood. There are many ways for people to theorize why some people see their lives flash before their eyes, but no concrete answer.