Teh sad reality is that Azula was never truly sane to begin with. She always had this very real need to be better than others. To quote that volleyball game, she put down that oppisite team, not out of rivalry, but because it would have been harder not to. in Smoke and Shadow, she does come back, just as bad as before. How was her sanity restored, you ask? By figuring out a new way to get into power. as Zuko said, she would never become Fire Lord. but she said she was okay with that, and by manipulating Zuko, she would be the true Fire Lord, in practice if not in name.