Well, as the Let's Play guy for Kingdom Hearts, I have some answers for you.
1. There's this thing about "light and darkness", going on so that wherever there is light, there is also darkness, and while Kingdom Hearts had the greatest darkness, NotAnsem wasn't prepared for the fact there was also the greatest light, and he got zapped. You could say that Kingdom Hearts was also the doorway into a "mirrorverse" of equal and opposite light and darkness, considered the "realm of darkness" to the main "realm of light" opening the door allowed for these two realms to rebalance each other, and since the realm of light was getting dark, the realm of darkness gave the light back.
Furthermore, you could also say that Kingdom Hearts is kind of a master boot record copy of the universe, or at least all the worlds devoured by the heartless to create that particular iteration of Kingdom Hearts, so what Ansem wasn't counting on was that as soon as the door opened, the light within would pour out to repair the damaged worlds (which it is explained it did in 2, and why Gummi Travel is different.)
I know, it's hard to understand, and I long held the suspicion that Kingdom Hearts was full of whatever it was someone yelled out loud at the time. If Sora had instead yelled "Kingdom Hearts is Cheetos!" NotAnsem would have totally been mauled by cheezy goodness.
Even if it wasn't light, NotAnsem probably still would have melodramatically died, as you'll notice both incarnations and his preincarnation was a scholarly sort, and you could say his campaigns were all research into his thesis. Which was then definitively proved
wrong, and he then experienced critical research based existence failure, as all scientists are wont to do.
2. Riku felt kinda bad about, y'know, betraying his best friend and destroying his home island, working for the people attempting to sacrifice Kairi to open a nether gate and most importantly allowing a creepy man with an alluring voice to jump his bones.
So when it's up to Sora to close an epically huge door (the automatic deus ex machina door switch must have been on the fritz) and an army of the strongest heartless are pouring down to escape into the realm of light with only Mickey Obiwan to defend the door, Riku felt a little keen on atoning for his mistakes by helping close the door before the heartless got out, and helping fight with the King against impossible odds.
So while he could have easily escaped and shut the door on Mickey, it would also have been kind of a jerk move to sacrifice Mickey like that, especially since it's implied that Mickey helped Riku stop being so heavily possessed too.
3. Sora could have hopped back to Destiny Isles, and that was why he saw Destiny Isles rebuilding itself, as the Realm of Light was trying to put the loose and scattered parts back on their homeworld, as Sora is native to that world it was trying to put him back.
However, if he'd gone to Destiny Isles, as Leon and Co had said: the barriers between worlds that prevented such travel would be back up, and finding both Riku or the King would have been impossible. So, just like Riku he made a small sacrifice to not just cast Riku and that mouse guy he never really spoke to in the lurch so he can go home and go back to doin' nothin' on an island.
The Land of Departure, where Sora and Co. head to, still allows for a degree of traversing between worlds, as it's like Twilight Town and TWTNW, in that it's between darkness and light, so it'd be the prime place to find Mickey and Riku anyway.
4. A lot of the plot holes made in KH1 were from translation errors or shit they immediately asspulled in the sequels, so that they could make more plot holes to fill in further games. The other side of Kingdom Hearts being "The Realm of Darkness" and the fact Kingdom Hearts is 'made', not found are prime examples. Some of the more egregious ones are fixed in the Final Mix, such as where "Oathkeeper" came from- Kairi had been making the charm with seashells during the first few days on Destiny Isles, so it wasn't actually her lucky charm, but something she'd made and had intended to give to Sora.
Kairi herself is given a lot of backstory with little context too, if you'll recall that trippy dream sequence where Sora flies to Kairi's childhood and hears the story of the Heartless from her Grandma, and you learned overall that she used to live on another world (Implied from the Cutscene to be Hollow Bastion) and was sent to Destiny Isles when she was too young to remember, and is also a princess.
Then when you learn the cluster-fck that is Hollow Bastion's past, you realize there's still a lot unexplained about Kairi's past, even with Final Mix and KH2's ansem reports explaining that NotAnsem in a moment of Dick Dastardly planning, strapped her to a rocket and sent her on a random course throughout the universe with expectations that she'd crash land on the planet that had the destined keyblade bearer. ASSPULL.
5. Final mix made a few plotholes by implying that Ansem wasn't really Ansem, the aforementioned why of Kairi, and implying that something else is created when someone becomes a Heartless-all leading to the plot of the second game.
Other things added are Final Fantasy Mainstay weapons, explaining how
Riku got sent to the Realm of Darkness (Ansem did a GTA on Riku by stopping him, forcing open his car door, and throwing him to the street. The street being DARKNESS!) as well as also giving Sora attacks and abilities he supposedly should have had but didn't.
If you were wondering where he learned
Zansetzuken in Chain of Memories, it popped up as a reward for popping Zisa, as well as a few other attacks that are considered Sora's mainstay repertoire in KH2 that seemingly popped up out of nowhere as the sequel demanded, but really weren't.
Any more questions? TL,DR? Did I trip over myself explaining a needlessly and intentionally ludicrously complex plot?