A combination of factors in both cases.
The important reasons for his rise to power included
The Great Depression and the Wall Street Crash which hit Germany particularly badly.
The humiliation and suffering caused by the conditions imposed on Germany within The Treaty of Versailles.
An underestimation of Hitler by his political opponents and indeed his supporters who thought they could control him.
His ability to tap into these factors and the latent and indeed active anti-semitism within German culture.
Considerable support for Hitler from powerful industrialists and from abroad, e.g. Henry Ford.
A series of spectacular successful foreign policy coups as Western powers repeatedly failed to stop him in the Rhineland, Austria, Sudetenland and Czechoslovakia.
Hitler's eventual defeat is inexorably linked to the course of World War 2.
After spectacular initial successes often against the advice of his generals, Hitler took increasing control of Germany's military strategy.
His attack on the Soviet Union in 1941 opened up a war on two fronts which was his generals' greatest fear. His belief that the campaign would be short similar to previous campaigns in the West meant that his troops were not equipped for winter fighting with terrible consequences.
Constant changes in strategy led him to fall out with experienced generals such as Guderian and he replaced them with sycophants such as Keitel and Jodl.
Decisions such as his refusal to let the German 6th army break out at Stalingrad led to enormous losses of both men and armaments.
His decision to declare war on the USA after Pearl Harbour when American involvement in Europe was by no means guaranteed was another major mistake.
By this time, one can conclude that the odds were so stacked against Hitler and Germany that his defeat was inevitable.