Also, Iran is nowhere like a dictatorship. Mr Ahmadinejad who was labelled as a dictator by the west, just lost an election one day. Can a dictator possibly ever lose an election? As for the Ayatollah, they aren't really politicians. More like Kings in the constitutional monarchies or say Japanese emperor - a figure of authority who has a big weight in taking decisions, but not an everyday ruler.
1. Supreme Leader has all the power and President's power is very limited.
2. Candidates are "vetted" by the regime. Therefore, people can elect but the choices are limited to a few people regime has accepted.
3. During Ahmadinejad, even the vetted candidate who was popular and got the vote wasn't really acceptable by the regime so they completely ignored the vote and just named Ahmadinejad as the winner.
Basically, the real government is the IRGC. Elected goverment is the one who does the legwork and also the blame because officially they are in charge but practically they are not.
It's like you have a boss who delegates you all the responsibility but none of the authority. You will be responsible but you cannot make any calls.