Because they declared them loudly.
When they launched the drone strikes on Israel, they gave Israel and the US warning time so they could be intercepted. The second time, they gave them much less warning time.
The Iranians have a long history of negotiating loudly via their actions, which anyone who's spent any reasonable amount of time studying Iran knows and has seen in action. They're really not a mystery, they're very transparent, we just don't like what they're saying.
David takes a small rock and whips it at a sensitive spot on Goliath’s ankles that most people don’t know about (Diego Garcia)
David knows Goliath will probably dodge it, and most likely kick it away given it’s importance, but there’s a point being made by shooting: if it hits then that’s a win, but if gets knocked down it’s a warning that they know where they need to hit for it to hurt