Satoru Fujinuma has the "Revival" ability, which allows him to go back in time before a life-threatening incident happens. We do know that he is not able to control this power (even if he can somehow help to summon it sometimes), but do we learn at any point how he obtained it ? Or did the author mention anything about this ?
⚠ The answer below contains spoilers.
It is never stated in the anime nor in the manga how he obtained this ability. We know that after the events in the last episode, he loses it and it never occurs again.
As the Boku Dake Wiki says:
Revival (再上映 (リバイバル), Ribaiburu, lit. "Rerun") is an involuntary special phenomenon exclusive to Satoru that allows him to jump back in time in order to rescue someone from a fatal encounter within his proximity.
Empirically, Satoru's capable of responding to Revival, as it occurs involuntary and often at random times. Fujinuma described his experience as a deja vu.
I don't think there is an official given reason for it, but after going over the story, I believe the power came about in response to Satoru's guilt.
As a child, he made no real effort to connect with Kayo. After she died, he felt awful for not doing anything to help her. His mother did her best to help him forget about what happened and let it go, and he more or less forgets about what happened, but the guilt never really stopped eating away at him.
Some time after this, he obtained the ability to jump backwards in short intervals, which lets him save people. Despite this, he still feels empty, because it doesn't help Kayo.
Over the course of the series he rescues Kayo and the other children that her killer murdered, and eventually brings the killer to justice in 2003.
In doing this, he is finally at peace with himself. And Revival never occurs again.
To me, there are two explanations for this.
One is that, like Kenya said, Satoru imagined the entire sequence of events, but not just when he was in his vegetative coma, but also before Kayo is to be killed by Yashiro. It could be that Satoru suffers from dissociative identity disorder and his intuition was acting as 'Revival' Satoru the entire time.
Or, it could be that Satoru was given this ability so as to protect others from the same fate Kayo fell to, but ended up being used by Satoru to save Kayo instead, which would eliminate the ability's reason for existence, allowing the events of the second, parallel 2005 to occur.
Recently read a review on this anime that made me want to cry on this ability, while it isn't how he got it, it is a lot like Butterfly Effect, the movie. Basically, the skill becomes chaos theory embodied in him as the anime goes on, but is never explained how it starts. We just never see the results really until the end.
Sorry, I can't agree with the existing answers. If this was some sort of dream-like dissociative disorder, then the final events would never have occurred. The coma occurred because the teacher tries to kill him and he survived the coma because the teacher escaped and killed many other children (or in the anime, he just waited for him to come out). Regardless, it was proved that the teacher did attempt those kidnappings before and was prevented by Satoru, hence why the teacher tries to kill him once he's out the coma.
My take on the reasoning behind the "Revival" is less a sense of guilt and more a sense of hopelessness and despair. Satoru never truly get guilt over what occurred because he never tried to befriend or knew about what was happening to Kayo. However, the events clearly took an emotional toll and that culminated as an adult when he now felt dead inside. That loss of emotion seemingly triggered the "Revival" and brought about a feeling is self-worth, which coupled with the return of the teacher and the death of his mom triggers within him the need to return back to where it all began. This also is hinted at by the first time he fully uses the "Revival", he could never control "Revival" however after being cornered by police and the overwhelming feeling of loss from the death of his mother he begs "Revival" to occur to save her. This is a full "Revival" and is the only way to save his mom.
Simple he is in a coma and his braining is dying so he has flashes of his life going forward where people in life die , his brain then starts to go into a seize like state which makes his brain repeat flashes (the illusion of going back in time) then because he is being revived after dying his brain repeats the flashes from the start of life to the end of it.) His brain is creating personalities, memories as his life is flashing before his eyes. Hence the personalities , people etc all all fabrications of his mind which is screaming as it dies. The human mind can create entire humans and personalities that don't exist by piecing information together.
This is one theory only.