I wrote a fairly long indepth character analysis of Azula on CAPSLOCK, so I'll try to remember some of it. Warning, this will be very indepth. Wall o' text is a'comin!
After Zuko was born, Ozai probably had very high expectations of him, thinking that Zuko would be naturally good at Firebending. When Zuko didn't show any, or little, abilities right away, Ozai saw him as a loss cause and gave up on him. Azula was born, and probably showed Firebending abilities very early on in life, and also the fact that she was a second born like Ozai, he felt even more attachment towards her. Ursa coddled Zuko because she didn't like the sight of her son struggling, and didn't do so with Azula because Ozai probably kept Azula away from her mother as much as possible, in fear of Azula becoming like Zuko.
Now, Azula might have been born competitive, like a lot of people are. Take that competitive nature, add being a prodigy, and Ozai constantly doting over her to become stronger than Zuko, or even stronger than Iroh. Ursa probably thought that Azula was too much like Ozai and didn't openly love Azula as much as she did with Zuko. Azula, who probably was very similar to Ozai at this point, still could feel rejection but didn't know how to express herself so she just kept that feeling inside.
As Azula progressed in her Firebending, and Zuko struggling behind, Azula also probably got her father's feelings that Zuko was weak and hopeless. Ursa most likely resented Azula's attitude towards Zuko, and like Ozai, gave up on Azula. However, Ursa did show signs once and a while that she hoped that Azula was different, but it never seemed to get through to her.
Mai and Ty Lee were probably the closed people she had who showed mutual love towards her. Though she seemed to take advantage of them, she also showed that she cared about them. In her own way of course. If suddenly, Mai finally confronts her and says that she loves Zuko more than she fears Azula, Azula's obviously going to react negatively to that. Then more unexpected, Ty Lee acts against her to protect Mai. It's not a sure thing if Azula more upset that someone stood up against her, or that her friends betrayed her just like Zuko had done not long before.
With the added weight of prisoners escaping the prison, her friends betraying her, and possibly her father seeing her as weak or something, it's no wonder that Azula would freak out. Especially if all your life people redeemed and feared you, and suddenly you lose all that.
If all that happened, Azula might start thinking of Ursa, the only person who never actually feared her. These hallucinations will probably start to make Azula realize this fact, driving her further into her insanity.
I'm not going to start up more theories, I think that's enough for now. I was starting to waver off anyway.