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.
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.
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.
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.
It could also be that the situation was extremely dire. For example, the troll was about to destroy something very important, like a magical artifact that could cause great harm if it fell into the wrong hands, and Hermione saw killing the troll as the only way to prevent that.
It could also be part of a larger plot in the fanfiction. For instance, the Slytherins might be trying to gain the trust of the other houses. By saving Hermione, a well - liked Gryffindor, they hope to change the perception of Slytherins in the wizarding community. Or perhaps they are secretly working against a common enemy who sent the troll, and saving Hermione is a step in that plan.
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 reason could be that she is in a desperate situation. Maybe she needs something for a very important spell or potion to save someone's life and she thinks Harry won't notice or will forgive her. For example, if there is a rare ingredient that only Harry has access to and time is running out.
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 be related to Ron's insecurities. He might be insecure about his place in the group with Harry and Hermione. Hermione is always so confident and sure of herself, and Ron might feel that he doesn't measure up. This could translate into aggression as a way of lashing out. Also, perhaps there's some external influence, like a dark magic object that's affecting Ron's mood and behavior towards Hermione.
One possible reason could be that Snape sees Hermione's value as a brilliant student. He might recognize her potential and not want it to be wasted just because of her dad's actions or situation. Maybe he has a sense of justice deep down, despite his often cold exterior.