Is that why the Nazis were prosecuted in an international court?
The problem with this question is that the Third Reich did a lot of horrible things. A lot.
Some of these actions were nominally legal, such as the expansion of persecution of (mostly male) homosexuals. §175 of the German criminal code, which criminalized was still on the books when Hitler came to power and while there were Weimar-era moves to decriminalize homosexuality, the Third Reich reversed such moves and strengthened the regimen of law and punishment for this behavior. There were also a variety of measures against both Roma and Sinti which predated the 1933 seizure of power but the Nazis likewise expanded and enforced. The expansion of restrictive laws or creation of new ones was greatly facilitated by the rather limited nature of German higher courts to declare the government's actions as unconstitutional or illegal. Even more damaging to the law was there was a strong tendency for German jurists to be "blind in the right eye," i.e. far more conservative and right-leaning in their sentences. The Nazi state rather easily "coordinated" the legal profession through purging out racial and political undesirables and ensuring that the law remained congruent with the nationalist ideology of the state.
But on the whole, a good many of the misdeeds of the Third Reich were not legal under German law. As /u/commiespaceinvader correctly noted in their answer to an unpleasant question:
The Holocaust was only legal if you either a.) are one of the Nazi jurists who with a lot of effort and mental gymnastics constructed a legal theory that stated that whatever the Führer ordered was to be considered legal or b.) consider every state action legal by the virtue that is done by a state organization, institution or authority. Even the most dedicated legal positivists I know off would not endorse that second interpretation.
It does not take much critical thought to see that the mass murder of Jews was an illegal act. Even by the standards of the Nazis set for themselves it was illegal. In the Nazi Weltanschauung Jews were a racial enemy of Germany no different than the other powers that it was at war with such as the UK. But Germany decided not to apply the rules of the Geneva Convention or other international regulations governing enemy combatants to both the Jews and the Soviets. This was one of the means by which the postwar tribunals such as the IMT at Nuremberg were able to prosecute Nazi war criminals. These Tribunals were not a case Nullum crimen sine lege ("no crime without law") as there were enough international precedents like the Geneva Convention or the Kellogg-Briand Pact to support the charges against the defendants. Although the prosecutors tended to bend some principles of Nullem crimen this was more to do with the related factors of the not very robust nature of international law at this time and the fact that the scale of Nazi crimes were unprecedented in many respects.
Now the Third Reich at places did try to frame its actions as in keeping with legal precedents. Hans Frank, the head of the General Government in Poland did go on a lecture tour in 1942 (!) after the SS arrested one of his cronies for fraud. He warned his audiences that unless certain parties *read Himmler) were not restrained, Germans could find themselves living in a police state. Most SD reports on Frank's tour indicate he received widespread applause and approval from his audience. The reports also castigated his defense of the law as "outmoded liberalism" and Hitler was incensed over the lectures. Rather than bringing SS abuses to Hitler's attention, it had the opposite effect for Frank and he lost most of his titles, but, in a move not uncharacteristic for the chaotic and polycratic state, Frank kept his position in the General Government. He continued to be something of an anemic loyal opposition in this position, belatedly trying to soften the anti-Polish rhetoric and policies of the General Government as it became clear that the Red Army was pushing German forces back into Poland. In a pattern of poor judgement, Frank believed that his diaries and lectures would vindicate him in the postwar period and dutifully asked to bring them with him when he was arrested in May 1945. At Nuremberg, his defense counsel Alfred Seidl brought up the lectures in Frank's testimony:
Seidl: Witness, I now come to one of the most important questions. In 1942, in Berlin, Vienna, Heidelberg, and Munich, you made speeches before large audiences. What was the purpose of these speeches, and what were the consequences for you?
Frank: The speeches can be read. It was the last effort that I made to bring home to Hitler, by means of the tremendous response of the German people, the truth that the rule of law was immortal. I stated at that time that a Reich without law and without humanity could not last long, and more in that vein. After I had been under police surveillance for several days in Munich, I was relieved of all my Party offices. As this was a matter of German domestic politics under the sovereignty of the German Reich, I refrain from making any more statements about it here.
But Frank's professed love of law could not hide the fact that he was guilty of war crimes. In his mentality, the law only applied to Aryans and those the Third Reich saw fit to include in this privileged order. It was a self-serving and rather pathetic defense of an legal order predicated upon terror and arbitrariness. But in a pattern similar to other defenders of police states, Frank's defense was all too typical: police states do not become police states until state power turns its attentions on the privileged.