I surprised you once, Ender Wiggin. Why didn’t you destroy me immediately afterward? Just because I looked peaceful? You turned your back on me. Stupid. You have learned nothing. You have never had a teacher.
After Mazer keeps Ender locked in his room and attacks him several times, Mazer immediately begins teaching Ender the danger of being too trusting and not looking out for himself. He explains that he wants Ender to understand that defeating his enemy should be his first priority. Even though Mazer seems harsh on Ender in this moment and throughout Ender’s education, Mazer
When I gave myself to starship travel, just so I would still be alive when you appeared, my wife and children all died, and my grandchildren were my own age when I came back. I had nothing to say to them. I was cut off from all the people that I loved, everything I knew, living in this alien catacomb and forced to do nothing of importance but teach student after student, each one so hopeful, each one, ultimately, a weakling, a failure.
Mazer explains to Ender how he found a way to stay alive to teach Ender how to fight the buggers. Even after destroying the buggers before, Mazer sacrificed everything to ensure that his knowledge would live on. Like Ender, Mazer focuses more on the survival of the human race than on his own happiness and innocence.
“And it had to be a child, Ender,” said Mazer. “You were faster than me. Better than me. I was too old and cautious. Any decent person who knows what warfare is can never go into battle with a whole heart. But you didn’t know. We made sure you didn’t know.”
After Ender realizes he destroyed the buggers, Graff and Mazer explain why they had to trick him, and why Ender had to be the person who performed the actual killing. Mazer explains that even though he defeated the buggers before, he knew he couldn’t perform such a feat again. Mazer also tells Ender how he learned from his time fighting that, to be successful, they would need a new commander as compassionate as Ender to truly understand the enemy.