With some help from one of my teachers, I think I figured out how Sherlock and Moriarty survived. My teacher suggested that Sherlock threw Moriarty off the building. From that I was able to figure everything out.
First of all, that wasn’t Moriarty. The face we know as Moriarty was ACTUALLY either an insane Moriarty copycat or someone working for the real Moriarty. (1) The real Moriarty wouldn’t kill himself. It would relinquish all his power and he’d just be insane rather than a mastermind (2) the real Moriarty wouldn’t kill Sherlock. He’s too obsessed with Sherlock to make him kill himself (3) The real Moriarty would know that Sherlock was setting him up at the end. Sherlock had his phone recording their conversation, so he was acting stumped and asking questions. Sherlock would never legitimately do that. He would try to figure things out, or have it figured out beforehand. And the real Moriarty, who is obsessed with Sherlock and studies him, would know Sherlock was out of character. Therefore, that wasn’t actually Moriarty.
Second, Sherlock threw fake Moriarty off of the building. Sherlock has obviously figured out Moriarty’s plan to try to make him kill himself, hence his behaviour acting stumped and recording it. He put fake Moriarty in a position to kill himself. Sherlock had come prepared. He brought a wig and switched clothes with fake Moriarty. He got either his buddies in the underground to collect and identify the body, or he went to Molly in private and got her to say it was him. After all, he’s a criminal. His body probably would have gone to the police after he was pronounced dead.
That’s my theory. There may be some holes in it. Feel free to point them out.