Iran attacked countries that played absolutely no role in the US and Israel’s attack on it, including some (like Oman) that have been fairly closely allied to the regime.
That goes far beyond what’s permissible in international law in response to an attack.
In my view the US and Israeli attacks on Iran were illegal, reprehensible, and deeply stupid. But that doesn’t mean Iran is allowed to do whatever it wants afterward, especially to countries not directly involved in hostilities. In this case Iran has also broken international law.