I agree. It's really stupid of the teacher to not just apologise and say it was a mistake to make that comment as the class was full of girls (bar one) - rather than admitting that he doesn't believe in "the ideology of transgenderism" and the other remarks which would be offensive to the boy.
I was actually going to agree with you and say that it's ridiculous that the teacher could be punished for saying "well done girls" until I saw the teacher's comments.