One reason could be that the troll is simply on a rampage and Hermione was in the wrong place at the wrong time. Trolls are not known for their intelligence, and it might have just stumbled upon Hermione while wandering the Hogwarts halls.
Well, in many such fanfictions, Harry might use his magic skills. He could cast a powerful stupefy spell on the troll to stop it in its tracks and then quickly lead Hermione to safety. Maybe he also uses his quick thinking and knowledge of the Hogwarts corridors to find a hiding place where the troll can't reach them.
In this kind of fanfic, one possible scenario could be that Harry uses his quick thinking and magical skills. For example, he might use a stunning spell on the troll just in time to stop it from harming Hermione. Another scenario could be that Harry lures the troll away from Hermione, using his knowledge of the troll's behavior. Maybe he throws something noisy in the opposite direction to draw the troll's attention.
His courage becomes more evident. By saving Hermione, he shows that he is willing to face great danger for his friend. This act of heroism can make him more confident in his abilities as a wizard.
Well, it could start with Hermione being in a vulnerable situation, like being cornered by the troll in a dark, damp dungeon. Harry, being the brave hero, arrives just in time. He might first distract the troll by conjuring up some annoying little creatures that the troll would start chasing. Then, when the troll's back is turned, Harry would grab Hermione and apparate them both to a safer place, like the Gryffindor common room.
One possible plot twist could be that the troll is actually under the control of a dark wizard. So when Harry saves Hermione, they realize that there is a much bigger threat at hand. Another twist could be that the troll turns out to be a transformed Hogwarts student, and they have to find a way to reverse the spell instead of just fighting it.
One possible scenario could be that in this fanfiction, Harry discovers that Hermione is being bullied by some dark - minded students at Hogwarts. He steps in immediately, using his skills and the respect he has among his peers to put an end to it. Maybe he threatens the bullies with exposure to the professors if they don't stop.
After Harry saves Hermione, their relationship could evolve in a more complex way. There could be a newfound respect between them. Harry might have a sense of pride in being able to protect her, and Hermione may feel a bit more vulnerable around him. This could lead to some awkwardness at first, but as they work through it, they become closer. They might start spending more time together, not just for school or magic - related things, but also just to be in each other's company. Their friendship could become the cornerstone of their lives, with Harry always being there to protect Hermione and Hermione always being there to support Harry with her knowledge and wisdom.
It could be some water - dwelling dark creatures. Maybe mermaids with a malicious streak or some sort of lake - bound demons that were awakened when Hermione got too close. They might see her as an intruder and want to harm her, which is why Harry has to save her.
In some fanfictions, Hermione might use her intelligence and magic skills. For example, she could use a powerful spell to create a distraction at the Dursleys' place. Maybe a spell that makes all the dishes in the kitchen start flying around, causing chaos. Then, while the Dursleys are distracted, she could quickly grab Harry and apparate away to a safe place, like the Burrow or a hidden wizarding location she has prepared in advance.