Becoming a dictator seems risky. Hitler could as well have ended up in prison for treason and/or murder, couldn’t he? So my question is... when taking over such a big nation that already has courts and judges and laws, where did Hitler start? Who did he get on his side to be confident enough to take over the country? And was he ever close to failing, was there ever a police or judge or prosecutor who claimed it was against the law?
Hitler became a dictator legally so the answer to your question is that I'm not sure many would have argued it was 'against the law'. Hitler was appointed Chancellor by the then President after a series of other failed chancellors. Hitler was a legitimate candidate for the chancellorship as he had the largest/one of the largest parties in the Reichstag (German Parliament). Hitler had run all his political campaigns on an anti democratic platform so it would have not been a surprise to the German people when he started removing limits to his powers. He did just that with a series of acts and decrees which were all legal. Germany had been a democracy for about 15-16 years when Hitler became Chancellor so they had no tradition in the practice and many Germans felt democracy had failed them considering those 15-16 years had been a disaster economically and socially for the German people. Hitler blamed democracy for (along with many other things) for Germany's problems and many (but by no means all) believed him.
The first act/decree that led to him being the dictator was the Reichstag Fire Decree issued in early 1933 by the German President following the Reichstag Fire that Hitler blamed on the Communists. This suspended many of the German people rights and liberties and allowed the opening of the first concentration camp in Germany shortly after which was used for political prisoners (mainly Communists and Socialists. This allowed Hitler to remove many of his opponents and their supporters on the far left.
Soon after the Enabling Act of 1933 was passed by the Reichstag which allowed Hitler to pass any laws via his cabinet rather than using the Reichstag itself.
Hitler then set up the Gestapo with Goring and Himmler who then merged it with the general police force thereby filling the German police with Nazis.
In 1934 Hitler carried out the Night of the Long knives which was a series of political assassinations/murders of Hitler's rivals and opponents. Most of the targets were part of the SA, a Nazi supporting paramilitary organisation. The SA however, were hated across Germany and viewed with distrust by the German military. The assassinations allowed Hitler to cut them off and therfore gained Hitler favor with many in the Germany military who would have already been supportive due to Hitler's rearmament program.
In August 1934 the German President Hindenburg died and Hitler used his powers to combine the two offices of Chancellor and President into a single position of Fuhrer. The military then had to make an oath directly to him to ensure their loyalty.
So, within a year of Hitler becoming Chancellor he had removed political opponents legally via the Reichstag Fire Decree and had the loyalty of the police thanks to the Gestapo as well the Nazis to make laws unilaterally thanks to the Enabling Act. At this point he would also of had the support of the military due to his rearmament policy.
Even the Night of the Long Knives was technically "legal" as he owned the fact he had organised and had the assassinations carried out for the security of Germany, passing a decree after the fact saying it was justified.
The Concentration camps and race laws expanded in 1935 with the Nuremburg Laws, making the rounding up of the Jews and their eventual genocide (along with other social and ethnic groups legal).
If Germans were to argue that Hitler's rise to power and actions were illegal, well that would be incorrect. If someone were to argue it was wrong, well were they going to complain to... the Gestapo? the military? Their local Reichstag representative who has no influence because the Reichstag signed away it's power in 1933 or is in a Concentration camp?
Before the Munich Putsch in 1923, Hitler ensured he had Ludendorff by his side. Ludendorff (along with Hindenburg) effectively controlled Germany in a military dictatorship during WW1. Additionally he was revered by Germans as heroes, one of his many exploits includes banging on the citadel gate of Liege with his sword hilt after a 2 week siege, thereafter all his opposition surrendered - effectively capturing the city single-handedly along with his brigade. Hitler knew having the once de facto leader of Germany on his side during the Putsch was important for morale.
Despite the failings of the Putsch, and arguably because of it's failure, Hitler's popularity rose exponentially. The judges at Hitler's trial were sympathetic to his side of the argument and allowed him to make prolonged speeches in the courtroom. The penalty for treason was death - Hitler got 5 years. He served just over a year of that. Due to the publicity of the trial, Mein Kampf sold well, his guards were friendly to him, he received letters from his fans and was allowed visits from supporters (i.e. Hess). After his prison sentence he was determined to reach his goals via politics, not force.
So to answer your question, no. From a historical standpoint, we look back at the Nazis and think 'how did this monster rise so quickly?' but in the context of the period things such as antisemitism were far more common. Additionally, this was happening over many years, with many Germans not being politically savvy, with (obviously) no access to Twitter or Facebook to see the latest bit of legislation Hitler had passed. As such, many only saw the admittedly brilliant speaker, and not the insidiousness inside of him. Hitler was extremely talented at hiding his true intentions, he deliberately didn't outline his policies, leaving them vague, in order to attract as many people as possible. Relying on his charisma to draw people in - which it did.
Eventually, people did begin to question Hitler's views, but they were powerless after the Enabling Act passed in 1933. This act gave Hitler dictatorial control and the power to arrest his political adversaries. His reasoning being the Reichstag Fire, which was allegedly perpetrated by a Dutch Communist. Anyone with dissenting opinions after this event were branded traitors and sent to concentration camps. Children were encouraged to report teachers who didn't promote Nazi ideals, judges had to be members of the Nazi Party, the National Reich Church was established and the Hitler Youth was made compulsory after 1936.
To conclude, Hitler never made it clear he wanted to install himself as a dictator, until he had the power to do so. Every single one of his power grabs was done under false pretenses - the threat of Bolshevism, the need of a strong leader, Jews taking over the world, etc - the first time Hitler explicitly announced his plans for the Jews was during his 'Prophecy' speech on Jan 30th 1939. Even then, he claimed, he would only destroy the Jews in self defense:
'If the international Jewish financiers in and outside Europe should succeed in plunging the nations once more into a world war, then the result will not be the Bolshevization of the earth, and thus the victory of Jewry, but the annihilation of the Jewish race in Europe!'
All of Hitler's actions pre-Enabling Act were legal. Of course they were opposed, but it was still viable for him to argue that he was working within the limits of democracy. After the Enabling Act was passed, it didn't matter if was he was doing was dictatorial - he kept his subordinates on a tight leash and placed his most trusted cronies, Himmler and Heydrich, in charge of the Gestapo and SS. Overheard talking bad about Hitler? Expect to be missing within the week. Heydrich didn't get the nicknames 'The Hangman' and 'The Butcher of Prague' for nothing. No one could talk to anyone in a position of power without the fear of being murdered, tortured or imprisoned.