Hitler was mad. No question. However the question is, if he was so mad he was unable to be responsible in a legal way for it. The question, if he was evil though is another one. But that is a subective, personal one, which has nothing to do with a scientific, historic point of view.
So yes, he was insane. And to my eyes evil. IMO no one doing that can not be mad or evil. But for the historic question, if he was so insane he wasn't responsible for his deeds, I mean if he should have gone to the gallows or into a booby hatch, I can not answer, as I have not so much knowledges about psychatry and psychology.
However some historic background:
Hitler was born in Braunau in Austria. His father abused him and after his death he quitted school although being shortly before the Matura (Austrian A-level). He wanted to become a painter, but the Academy in Vienna does not take him. He could have started architecture there, but he needed therefore an A-level. So he has to paint post cards to survive in Vienna. In this time some Jews seem to be his clostest friends, nonetheless due to an extremely antisemitic mayor and environment he comes in contact with that ideology, especially some antisemitic papers by the Czarist secret service, made to agitate against Jews. Shortly after he flees to Bavaria, Germany, to avoid doing his military service in Austria. Nonetheless, when ww1 broke out, he cheered with the masses and is one of the many to conscript themselves willingly. He serves in ww1 at the western front, where he was wounded. He also got the Iron Cross, but is not promoted over the rank of a corporal. He was wounded and was in hospital when the German armies collapsed. After that Hitler joined for a short time a left radical Arbeiter- und Soldatenrat, but soon after, and as the left rebellions did not succeed, he joined as one of the first the NSDAP. IIRC he was the 32nd member, but got the number 532 in his party book, to push up the member number at least to others. The then DAP is only a small party, which are numerous and most of them have a short life. The "crème de la crème" of the German people is now entering such parties. Such as a fighter pilot who is a junkie (opium), Göring, Goebbels, and so on. Shortly after the party is renamed NSDAP, what is not more than a PR gag to get votes from all political positions. Hitler also tries a coup d'état in Munich, but fails. Not for the first time he escapes death only barely as the man next to him was shot. After a small imprisonment in Landshut he writes his Mein Kampf and becomes a multi millionaire because of that book. He rejoins the political theatre soon. In the times of the crise of 1929-1933 many elect his party not because his antisemitism, but depite it. Most of them are protest electors. However the president, Hindenburg, declines to take him as chancellor, as he is only seen as the Bohemian Corporal. But Hindenburg is finally persuaded to take him. But never convinced. Later Hindenburg saw his mistake but feared a civil war if he would try to dismiss Hitler. Due to the early successes Hitler becomes even more megalomaniac. But he does not see that he is getting the fruits others worked for, and so started to do things on his own. Most of them are catastrophes. Also his antisemitism now get an even more radicalization with the Holocaust. As it is obvious the Nazis would loose the war, he gives the Nero order to destroy everything in Germany as the German people did not deserve to live further on, as it was monor to the other races. This order was not executed. On April 30 he committed suicide with his just married wife, Eva Braun, and his dog, Blondie.
New president is Dönitz, who does not get the news he is until another day later, after Goebbels committed suicide. After a small "talk" with Himmler Dönitz releases all NS minister. A few days later Germany surrendered.
Adler