One possible motive could be his love for Harry's mother, Lily. Even in the fanfiction, this could be a driving force. He might see helping Harry as a way to atone for his past actions towards Harry.
Snape could be motivated by his sense of justice. He might realize that Harry is the key to defeating the true evil in the wizarding world. By helping Harry in battle, he is actually fighting for the greater good, despite his past associations with the Death Eaters.
In the fanfiction, Snape might help Harry in battle because he wants to prove himself. He has been a complex and often misunderstood character. Helping Harry could be his way of showing that he is not all bad and that he can make a positive difference in the fight against the dark forces.
Power. Voldemort might see Snape as a means to gain more power. Snape is highly intelligent and skilled in the Dark Arts. By caring for him, Voldemort could be ensuring that Snape remains loyal and continues to use his skills for Voldemort's benefit.
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's help could significantly change the battle outcome. His knowledge of dark magic and Hogwarts' secrets could give Harry an edge. For example, he might know of hidden passages to outmaneuver the enemy. His potions skills could also provide Harry with useful concoctions for defense or offense.
In some fanfictions, Snape might be working with Voldemort because he has been blackmailed. Voldemort could have found out some deep, dark secret about Snape and is forcing him to cooperate. This could be related to Snape's past or something he has done that he doesn't want to be made public.
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.
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 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 reason could be that he realizes Harry has a lot of potential and wants to nurture it. He sees that Harry is in a difficult position, being the target of Voldemort, and decides to help him despite their past differences.
One possible plotline could be that Harry breaks a major Hogwarts rule, like sneaking into the Forbidden Forest. Snape catches him and decides that a severe punishment is in order, which in this case is spanking. Another could be that Harry fails a very important Potions test repeatedly, and Snape, frustrated with his lack of progress, resorts to this extreme form of discipline. However, these are all just fan - created ideas and not part of the official story.
One possible motive could be jealousy. Snape might be really good at certain subjects like potions, and the Marauders, being competitive, might bully him to make themselves feel better.