There are civilian facilities on the grounds of US military bases, both at home and abroad, including schools.
Department of Defense Education Activity (DoDEA) schools give free education to active-duty MilKids, pre-k to grade 12. View eligibility requirements.
www.militaryonesource.mil
That Iranian girl school wasn't opened "yesterday". It was known, and should have been taken into account when planing the strikes - tomahawk missiles have a CEP (Circular Error Probable, call it a margin of error) of up to 10m, so none of them should have been launched at coordinates located closer than that, from the school. Unless wrong intel was given.