In Matilda, there is no speculation about how Miss Trunchbull became a headmistress even though she hates children. Here is a theory as to how she got her job. There's a reference to the musical and to the book, see if you can find them!
The Trunchbull's Great Secret
Agatha Trunchbull loved being a prefect. Barking out orders to the first years and seeing them scatter as she bounded toward them was such fun. The other Slytherins feared her, even those older than her, and she loved the terror that would grip them when they found her marching toward them, inspecting them for anything that could possibly be a violation of the rules.
She could hardly believe that, five years previously, she had no idea she was a witch. She didn't think much of her family anymore; what with her mother dying soon after her wretched sister was born (Agatha thought that her mother was probably a witch who gave up the craft although no one would tell her for certain). To her great delight, she had found her sister to be nothing more than a filthy Muggle. While her sister trained in gymnastics (she had high hopes to become an acrobat, a dream Agatha found ridiculous), Agatha trained to become a witch. Even though the elder sister had been exposed as magical, her father still preferred the younger sister. But Agatha knew that one day she would find a suitable loophole in the magical law and get her revenge on her father and sister.
That day was a gloomy Thursday in April. Professor Horace Slughorn, head of Slytherin House, had told her to come for her career evaluation during Transfiguration. Agatha was slightly peeved by this; she relished any opportunity to show up that Gryffindor show-off Minerva in her favorite subject, but she knew that the career consultation was important. So at eleven am sharp, she could be found outside Slughorn's office. She knocked.
"Come in, come in!" said Slughorn, looking excited.
Agatha marched into the office and sat herself down at his desk. She was certain not to slouch; slouching was a horrible habit that she had shouted mercilessly about to a few Ravenclaw first years on the way to Slughorn's office (they had started crying but this seemed to give her even more satisfaction).
"Ahh, Agatha Trunchbull." Slughorn said, reading off a bit of parchment in his hand. "Yes, I have heard multiple complaints about you from fellow students."
"I don't know what you're talking about, sir." said Agatha crisply. "I merely enforce the rules."
"Ahh yes, my dear girl but perhaps a bit too sharply, if I may be blunt. A bit of leeway in the future would be preferable, yes. It would certainly get the other teachers off my back about reigning you in."
Agatha flinched slightly at being referred to as a 'girl.' She had always hated the term and preferred to be referred to as a young woman. She had hated being a child so much. Being an adult meant having power. Being a child meant being subject to authority. Even now, she had to force herself to be respectful to her teachers, though sometimes she dearly wanted to hex them.
"As of yet, I do not know what it is you're hoping to accomplish." Slughorn continued, oblivious to her reaction. "I certainly think you could have a lucrative career in Magical Law Enforcement."
"No, sir. I would prefer to work with Muggles." Agatha said, keeping her voice steady.
"Oho!" Slughorn exclaimed, putting down the piece of parchment. "That's certainly not what I expected, my dear girl, not at all."
Agatha flinched again but Slughorn either didn't notice or didn't find it prudent to ask about it.
"Since I was a… a child, I liked to watch Muggle sports." Agatha explained, keeping her voice crisp and clear. "As the first female Beater Slytherin has had in decades, I have developed incredible upper body strength. I was thinking of entering the Muggle Olympics."
"That is certainly a worthy goal but I'm afraid it won't pay your bills." said Slughorn, now staring at her. "Are you implying that you would like to take on a Muggle career?"
"Yes sir. I grew up around Muggles and they have a very different way of life. They don't follow the rules. They think they're so superior to each other. The behavior needs to be… taught out of them at young age. It is my ambition, Professor Slughorn, to become a Muggle headmistress at a primary school."
Slughorn kept staring at the rather large adolescent in front of him. She had so much potential, he thought, and he had so many connections at the Ministry. However, here she sat, looking determined to work with Muggles instead of her own kind. He admired her ambition but something about this was rubbing him the wrong way. He had learned long ago never to question a student's ambitions and he certainly would never stand in the way of them. To do so would be overstepping his bounds as a teacher. After a moment of silence in which Agatha did not break his gaze, he smiled.
"If that is your ambition, Miss Trunchbull, then I would suggest Muggle Studies. And perhaps continue the base subjects, you know, Herbology, Defense Against the Dark Arts, Transfiguration, Charms, and, naturally, Potions."
Agatha nodded once to show she understood.
"You also must attend a Muggle university after your time at Hogwarts in order to become a headmistress." Slughorn picked up the parchment again. "I have excellent contacts at the Ministry and can get you placed at a top university with a sports program for your… other ambition."
"That would be acceptable, sir." Agatha said.
"Very well then. If you have any questions, please don't hesitate to ask." Slughorn smiled kindly at her.
With that, Agatha stood up straight and marched out of the room. As she turned to open the door, Slughorn could have sworn he saw a glimmer of glee in her cold gray eyes.
"Agatha Trunchbull, I see you have a rather impressive resume."
Agatha nodded at Mr. James Trilby, the Department Head of Education. The man didn't look up at her.
"Olympic champion, very nice. I'm sure you can tell your students all kinds of stories. However, I feel a bit wary about some of the letters of recommendation I received with your application." He looked up at her. "It's almost as if they were written by the same person."
Unbeknownst to him, Agatha slipped out her wand.
"Confundus."
"All in all, your application is exemplary. We would love to have you on board. We can offer you a job right away, in fact. Crunchem Hall Primary School is in need of a headmistress. Can you start at the beginning of term?" Mr. Trilby continued to stare at her, his gaze a bit unfocused now.
Agatha smiled and leaned forward.
"I would be delighted."
