In her fifth year Hermione clearly knew the Defence Against the Dark Arts textbook, upon which the theory exam was partly based, back to front.
“What is it this time, Miss Granger?”
“I’ve already read chapter two,” said Hermione.
“Well then, proceed to chapter three.”
“I’ve read that too. I’ve read the whole book.”
Professor Umbridge blinked but recovered her poise almost instantly.
“Well, then, you should be able to tell me what Slinkhard says about counterjinxes in chapter fifteen.”
“He says that counterjinxes are improperly named,” said Hermione promptly. “He says ‘counterjinx’ is just a name people give their jinxes when they want to make them sound more acceptable.”
Professor Umbridge raised her eyebrows, and Harry knew she was impressed against her will.
(Order of the Phoenix, Chapter 15, The Hogwarts High Inquisitor).
She was also a very capable witch who was incredibly talented. She excelled at performing spells from a range of different specialties, including Defence Against the Dark Arts. She'd also received specialist tuition from one of the only students who was better than her in that subject (Harry) as part of Dumbledore's Army.
Cumulatively, there are plenty of reasons why Hermione could be expected to get an Outstanding O.W.L. in Defence Against the Dark Arts. Which is why it's surprising when she only gets Exceeds Expectations.
“Hermione?” said Ginny tentatively, for Hermione still hadn’t turned around. “How did you do?”
“I - not bad,” said Hermione in a small voice.
“Oh, come off it,” said Ron, striding over to her and whipping her results out of her hand. “Yep - nine ‘Outstandings’ and one ‘Exceeds Expectations’ at Defense Against the Dark Arts.” He looked down at her, half-amused, half-exasperated. “You’re actually disappointed, aren’t you?”
(Half-Blood Prince, Chapter 5, An Excess of Phlegm).
It's especially strange that Hermione got top grades in literally every other subject.
Why didn't she get an O in Defence Against the Dark Arts?