Actually Hitler was (approximately) elected/appointed in a legitimate election.
In the July 1932 German elections Hitler's National Socialist German Workers' Party (Nazi) party won 230 out of 608 seats in the German REichstag, and were the largest party.
The two non-democratic parties (The Nazis and the Communists - who refused to work together, or with anybody else for that matter) between them held an absolute majority so the Reichstad was non-functional and no stable government could be formed.
President Hindenburg (Who had indeed be legitimately elected when he defeated Hitler in the 1932 elections) appointed Hitler Reich Chancellor at the head of a cabinet including only a minority of Nazi ministers on January 30th, 1933.
Needless to say, things go rather less democratic in German going forward......
NOTE: - In the german system the President was elected from all the people and has some "head of state" functions such as constituting a government within the Reichstag. Hitler was appointed to a position more or less like Prime Minister in the British system