Here is my take on, the NDE.
Even though a person may stop breathing and his or her heart stop pumping - clinically dead - the brains may not have cease all functions or brain activities. Not "brain dead", yet.
As I am no doctor or psychologist, and as I have no experience in NDE or know anyone who have, all I can do is to share what I think of possibilities...my opinion.
We know that people who suffer from oxygen deprivation, and breathing in carbon dioxide, this can result in hallucinations.
The brain tissues and cells require oxygen to replenish it to normal healthy and functioning tissues and cells, via blood. Working cells will use the oxygen, and after the energy the cells exerted, carbon dioxide are carry out as waste, through the blood.
So essentially the oxygen in, carbon dioxide out, require blood circulation, and therefore pumping heart and functioning lungs.
But when a person's heart stopped and the person is not breathing - thus the person is clinically dead, then the circulation will stop too.
My guesses are that sometimes when a person are clinically dead, don't necessarily mean the brain all activities immediately stop too.
There may be portion of the brain that still functioning, active, so the electro-chemical pulses in neurons (brain cells) are still active.
So since the blood circulation stopped, the brain is not getting any more oxygen, and there would be built up of carbon dioxide trapped in all brain cells.
So a person can experience some forms of hallucination-like experience.
If unconscious person, like those in a coma can dream, why not a person who is near dead, before reviving?
Not all dreams are the result of REM sleeps, where you can tell and record & measure the involuntary movements of the eyes. A comatose person would not have REM sleep, they are unconscious, not asleep.
Also some people do dreams while not in REM sleep, meaning there are no active eye movements, called "non-rapid eye movement" sleep or NREM sleep.
My guesses of what people experiencing don't required the woo-woo