How I see it is for one, there's Sora. When your heart separates from the body and soul, it becomes a heartless, just like in Kingdom Hearts One when Sora watches a shadow attack a man, then his heart to float out and become a heartless. Like Leon in the first game said, everyone has a little bit of darkness in them. If you get too much, BAM! You're a heartless. Lose your heart? Heartless.
Alright, so Sora stabs himself with Dark Riku's keyblade which extracts hearts. Sora loses his heart and so his heart becomes that silly Shadow, then his body becomes Roxas. So Roxas is made, there. Namine tells him that he is part of Sora, obviously implying that Roxas is a nobody. So Roxas is there. When Sora wakes up, Roxas (in a sense) stays in existence but he's also in Sora now. Now at the World That Never Was, Sora fights Roxas. Obviously Roxas managed to get out and decided to duel Sora. Afterwards, after beating one of the Xemnas fights, Namine shakes hands with Kiari and Kiari becomes whole. Same with Sora and Roxas. So Roxas has been around the whole time, but just not showing up, up until then.
So when they combine, Sora is now completely whole, just him, just Sora. But at the ending scene, it flashes from Sora staring at Kiari to Roxas and Namine, meaning that they're still there, but just not in a physical sense. So to explain Sora, it's obvious how he caused Roxas to appear, but Roxas was simply (in a sense) inside of Sora most of the time. Then there's Kiari. As we know, in the first game, in The Secret Place, Sora tries to catch Kiari flying in the wind coming from the door, but instead, Kiari's heart goes into Sora, so now Sora has Kiari and his heart. Now, because Kiari lacks a heart, she's lifeless and somewhere in the world, Namine comes into existence. Now when Sora stabs himself with Dark Riku's keyblade, he releases his and Kiari's heart, and Kiari wakes up again. Namine is still out there somewhere, probably being forced to help by Marluxia for the GameBoy game. So Kairi wakes up, but Sora becomes a heartless, but when they hug, the light from Kiari (one of the princesses) showed him the way to the light and he found his heart again, causing him to become himself again. (Of course Roxas is still roaming around, of course what he's doing is unknown.)
Finally, after the Xemnas battle at some point, Kairi with Namine and Sora with Roxas, they combine, and they make one (but each is still there), then shortly after, the game ends. Give or take, personally I find my idea most accurate, but in recap. Sora gets Kiari's heart. Namine is made. Sora loses his and gives Kiari her heart back. Roxas is made. Kiari (a princess) wakes up. She helps Sora find the light. A spar with Sora and Roxas at the World That Never Was and a meet-up between Kiari and Namine. With the help of girl power (YEAH!) they get to the tower. Kiari+Namine and Sora+Roxas. We're a happy family. End.