Iran has it's own internal politics and factions it needs to appease.
This is true of most countries too.
The US invasion of Iraq had far more to do with internal politics than it did with any actions of Saddam.
The current elected leader of Iran was actually the concillatory to the west candidate, elected when tensions were not quite as high.
Now that tensions are high, he has to prove he's not too weak to his own constituency, as the Persian people come together under what they consider to be an unjust attack.
Again, this is true in general for most countries. Foreign policy is driven far more by domestic politics then most people consider.