Good thing you missed the point which is framing Dany as some unhinged psycho before episode 5 was silly.
Who framed her as an unhinged psycho before episode 5? The fans? Because the show sure didn't.
The show framed her as an extremely powerful woman who had suffered a lot of loss and wound up basically alone in the world, with all of her trusted friends and advisers either dying or betraying her. She has always thought she knew what was right and felt that nobody she currently knew could give her any sound advice so she followed her own heart and disregarded what they all wanted.
When the bells rung she was feeling all of the anger from losing all of her friends, half her army, being distrusted by the entire continent, and finally she won. But she didn't get to vent any of that anger. All of this was Cersei's fault. But she didn't get to kill Cersei or her soldiers, she just destroyed a bunch of ballistae and knocked down a gate. She was furious that she was put into this position and had no outlet for her fury.
So she took it out on who she thought were her enemies. She would be killing them all anyway, just executing them after the fact, since that's what she does to people who choose to work for her enemies. In her rage she didn't seem to care that she was killing innocent civilians in addition to Lannister soldiers. But to her those innocents were put there by Cersei to exploit her mercy and use it as a weakness. So killing them wasn't Dany doing wrong, it was Cersei doing wrong and Dany proving that she is not weak.
Nothing about any of these episodes showed Dany as an unhinged psycho, and people who see that are really missing the plot. Dany has always,
always been someone who believes she was destined for greatness, and that greatness was hers by right. The majority of the show had her righting wrongs and killing people who deserved to be killed, further convincing Dany that she and she alone knows what's right in the world. The more power she got the more she was convinced that she was going to do the right thing and punish all of the evil people in the world.
The problem is that power corrupts. She knew it was right to burn King's Landing because she has always known what was right, and this has been proven time and time again throughout her journey. Tyrion's many failures as her adviser? Further proof that she was right. Jon telling Sansa and Sansa getting word out? Even more proof that Dany was right, that's exactly what she said would happen.
So Dany, basically alone in the world with nobody to trust, knows in her heart that what she wants to do is the right thing to do. Everyone else has led her wrong. She alone is right. Therefore she was able to justify her actions, rationally. Not as an unhinged psycho.