What everyone else said, but also Iran probably informed the US through an intermediary when they are going to launch from where they're going to launch and what the trajectories were going to be.
This would allow them to have their proportional response, but also de-escalate with the US, allowing them to shoot it all down, and at least from the US's perspective prevent upward escalation
you have no idea how much that happens with foreign policy. it's not about right or wrong when it comes to foreign policy. countries don't have friends or morals they have interests both international and domestic. That can change on a dime.