In the fanfic world, it could be that Snape's harsh treatment of Harry over the years finally reaches a breaking point for Harry. All the pent - up anger, resentment, and the feeling of being constantly bullied by Snape might explode when there is some sort of final straw. For example, if Snape were to publicly humiliate Harry one too many times and then there is a magical accident during their confrontation that results in Harry lashing out and killing Snape.
Perhaps in the fanfic, Snape discovers a powerful and dangerous magic that he wants to use for what he believes is the greater good, but Harry sees it as a threat. Harry has always been wary of Snape, and this new discovery could be the tipping point. Also, if Snape were to make a deal with a dark force in order to gain knowledge to defeat Voldemort but Harry misinterprets his intentions, it could lead to Harry killing Snape.
One possible motive could be that Snape is still deeply influenced by his loyalty to Voldemort in this fanfiction. Maybe Voldemort has some hold over him that forces him to do the unthinkable. Another reason could be a misunderstanding. Snape might believe that Harry has turned to the dark side or is about to, and he decides to take preemptive action to stop what he thinks will be a great evil.
One possible motive could be a misunderstanding. Maybe Snape is framed for something really bad, like a dark magic plot against Hogwarts. Harry, in his haste to protect the school and his friends, believes Snape is guilty and takes drastic action. Another reason could be if Snape accidentally endangers someone Harry loves dearly, like Ginny or Ron, and Harry's emotions get the better of him in the heat of the moment.
One possible motive could be a severe misunderstanding. Maybe Harry is tricked into believing that Snape and Moody are involved in some dark plot against him or his friends. For example, if there were false evidence planted that made it seem like they were working for Voldemort again. Another reason could be that he was under the influence of a powerful dark magic that clouded his judgment and made him act out of character.
Another motive might be related to a dark object influencing her. If Hermione came across a cursed object, like a dark locket that amplified negative emotions such as envy or fear, it could drive her to kill Harry. Maybe she started to envy Harry's fame and the special attention he always got, and the locket pushed her over the edge.
Maybe Fudge was starting to turn against the wizarding community in more extreme ways. For example, if he was planning to persecute Muggle - borns more harshly or side with the Death Eaters secretly. Harry, being a defender of justice and equality in the wizarding world, would not tolerate such actions and might have been pushed to kill Fudge to stop his evil plans.
Differing ideologies during the wizarding war. If James was seen as a threat to Snape's side (even if Snape was on the wrong side, from a moral perspective), Snape could justify killing him. For example, if James was too aggressive in fighting the Death Eaters and Snape thought it would lead to more bloodshed, he might take matters into his own hands to stop James.
Well, it could be that Snape is wrongly accused of a great crime in this fanfic, and in the heat of the moment, someone attempts to kill him. Maybe it's a misdirected act of revenge by someone who thinks Snape is behind a series of dark events at Hogwarts. But of course, the truth might be far more complex and intertwined with the overall politics and secrets of the wizarding world.
In some fanfictions, Snape could have his own personal vendetta against Dumbledore. Maybe Dumbledore has wronged Snape in the past, and when he sees Harry as a potential victim of Dumbledore's schemes, he decides to help Harry. Another reason could be that Snape has a new understanding of the prophecy and believes that Dumbledore's way of handling it is wrong, so he steps in to help Harry.
Snape could also be acting out of a sense of justice. Lucius was a Death Eater, and Snape, despite his own past as a Death Eater, had turned against Voldemort. Saving an innocent, especially Harry's daughter, from Lucius would be in line with his new allegiance to the side of good.
One possible motive could be Snape's complex relationship with Harry's father. Snape might see Harry as a way to get back at James in some twisted way. He could also be acting out of a sense of duty to the Dark Lord, believing that taking Harry by force is part of some larger plan to gain power or favor.