i suppose Iran's and Russia's situations aren't directly comparable
US was never going to enter the war directly to protect Ukraine
whereas it is absolute certainty US will enter the war to protect Israel if it is legitimately threatened
still, Iran is choosing to avoid war whereas Russia decided to be macho about it
i doubt there was really no way to avoid it. i think Putin simply decided that a war would benefit his chances of holding on to power, same as how Zelensky saw it as well.
ultimately the war benefits the governments on both sides who grow their power, while the people pay the price.