Is there a scientific explanation for such experiences ? As in is there a reaction in the brain etc. ?
There is indeed.
If there is indeed a reaction in the brain who could explain these phenomenon, then how on earth did it developp in an evolutionnary pattern and what is the advantage from a natural selection point of view since it happens only when you are dead ?
The reaction is oxygen deprivation. The brain starts losing it's fule, and the cylinders begin to misfire. It dredges up half-remembered bits, combines it with any sensory input still getting through , and just like in a dream, attempts to create a story out of it as best it can.
It has been noted many times by people, especially in the air force, when they are in the high speed spinning contraptions that simulate G forces encountered in planes or rockets. WHen they spin it up so fast that blood literally can't pump all the way up to the brain, the people begin to hallucinate, they see bright lights, they feel a sense of calm, and they see loved ones that may or may not be dead. Some people even get on with the sole intention of bringing about that state.
For some actual experiments involving fighter pilots and centrifuges, you might start here.
Radiolab: Podcasts | WNYC Studios | Podcasts