You are quite right. As I have posted before:
The Shah was the reining monarch of Iran before Mosaddegh became Prime Minister.
Mosaddegh was never elected Prime minister.
The Iranian constitution gave the power to the Shah to name and remove the Prime Minister.
Mosaddegh was part of a coalition that included the communist Tudeh Party and hard line Islamists including the mentor of Khomeini.
Mosaddegh replaced the PM who was assassinated by the Islamists.
Mosaddegh had family ties to the Qajar Dynasty, that the Pahlavis had replaced in 1925.
At the time of the so-called “coup” Mosaddegh had lost almost all popular support, including amongst the hardliners. And that he tried to illegally dissolve the legislature.
There are many people who argue, including on this forum, that “The Shah” didn’t exist prior to 1953 and was an office formed by the “1953 coup by the CIA that installed the Shah.” The Shah was a monarchy that went back over 2000 years. The Shah in power in 1953 ascended to the throne in 1941.