The U.S. didn't install the Shah. He'd been in power since 1941, when the Anglo-Soviet invasion of Iran forced the abdication of his father. He didn't have as much power as his father, so there was a power struggle between him and members of parliament, but he still wielded a great deal of political power in the country pre-1953. One only need look at the 1949 constitutional assembly, where the Shah sought and succeeded at getting changes to the constitution made that gave him greatly enhanced powers.
The parliament while Mossadegh was prime minister was democratically elected (though Mossadegh was appointed by the Shah, per the constitution). But by the time he was removed, Mossadegh had dissolved the parliament and was ruling by fiat based on a rigged plebiscite (his administration claimed the result was 99.9% in favore of the plebiscite[1]).
The U.S. certainly conspired with the Shah to oust him, but it seems like their initial plans failed (certainly, the plotters seemed to think it failed), and royalists in the Iranian military were ones who ultimately removed him.
The whole thing was a fairly complex situation that tends to get reduced to a simplistic soundbite with little connection to what actually happened.
> The parliament while Mossadegh was prime minister was democratically elected
> (though Mossadegh was appointed by the Shah, per the constitution)
This is the case in almost all parliamentary democracies. The head of state (either the president, the monarch or the viceroy) invites the leader of the largest party or coalition in the parliament to form the government and become the prime minister.
> This is the case in almost all parliamentary democracies.
Iran _wasn't_ a parliamentary democracy at the time. It was a constitutional monarchy where an unelected monarch wielded significant political power. As I noted, he had just had the constitution changed a few years prior to increase the political powers granted to him (against U.S. objections, it should be noted).
Does that include when he had fled to Italy in 1953? The reports were he had little desire to go back to Iran, and the CIA and SIS met trying to figure out how to get him to go back to Iran
> the Iranian military were ones who ultimately removed him
That's how it usually happens, the military elements with contact with foreign powers are usually who do in the local nationalists.