(In 1991, the United States relied on the F-117 Nighthawk to penetrate Baghdad and launch salvos against radar and SAM sites. Simultaneously, Tomahawk cruise missiles were fired against similar communication and defense sites. In this war with Iran, the F-35 and B-2 have been used for stealth missions).
Recall that the Serbs shot down a Nighthawk when they were in a similar situation to Iran. They kept some good AA missiles in reserve and used a system of spotters and just waited for an opportunity. Its likely that similar tactics were used by Iran.
Also recall that the Houthis, armed and trained by Iran, gave F35s some close calls over Yemen.
https://www.twz.com/air/how-the-houthis-rickety-air-defenses...
In short, it took 2 rare events to occur for it to happen.