This is a bit simplistic but, if you get rid of unions, good teachers can negotiate their own salaries and get paid more. Teaching becomes a more attractive profession. Good teachers who left the market come back in. No more teacher shortage.
I don’t think you can fix a lot of the problems with the teaching profession while unions exist.