That’s only part of the equation. In states with strong teacher’s unions, those districts offset costs by increasing class size and cutting funding to programs that fill the funnel of next generation teachers, and those chickens are coming home to roost.
The fact of the matter is that no one wants to pay the taxes required to fund quality education for everyone, and even in areas where collective bargaining is strong, unions are left fighting for crumbs. You are seeing this play out in other ways in manufacturing and construction due to automation.