Why assume it wasn't an intended target?
Where would you stick sensitive stuff or the most important stuff if you were Iran in order to try and protect it best from a possible Western attack?
If it's right next to a military base who is to say you wouldn't have a shed load of things under the school. It's not like we have seen this in Gaza and it's not like we haven't seen Israel willing to target.
We know that unwillingness to target civilians is only restricted to the west and it's likely that Iran would capitalise on this.
The difference now seems to be that Israel is no longer adverse to targeting such places where civilian shields are being used.
It's deeply uncomfortable and at odds with Western thinking. But that's the point. It's a form of built in propaganda shield because it's a known Western 'internal political weakness'.
Iran is using multiple target to try and force a diplomatic settlement at this point. It's targeting Dubai airport for a reason - because it will put the most pressure on Western and Gulf governments. Remembering how many influential western billionaires live there and how many Western tourists there are there.
It's targeting the oil rigs because that's going to drive up prices. It's targeting the straits because that will stop the flow of trade and drive up prices. It's targeted neutral Oman who were facilitating talks between the US and Iran because it wants to force Gulf states diplomatically to tell the US to stop.
It's actually a race against time on both sides. The US has a limited number of missiles it has it can use to take out Iranian missiles and drones. Iran has limited launch sites and drone storage facilities. It's who can wipe out the others capability first really.
But this also suggests that this stage will be short - air superiority has been key in early engagements involving the US. You will then have longer term security concerns but they will be of a different nature and less frequent.
There's also implications for Ukraine here too. Iran has been supplying Russian with drones. This is probably going to knock out this capability. It is also going to drive up demand for Ukrainian drone tech....