Maybe in a very dark and twisted fanfic, Naruto could be possessed by some evil force. This would override his normal sense of self and his love for his friends, causing him to harm them.
Another possibility could be extreme misinformation. If Naruto was tricked into believing that Sasuke and Sakura were a great threat to the village or to him personally. He might take drastic actions in a moment of confusion and fear. But again, this is very far from his true character as we know it in the original series.
In a fanfic that explores a completely different Naruto universe with different moral and ethical values, Naruto could have been raised in a way that made him more ruthless. For example, if he was trained by some evil entity from a young age and taught that power and dominance are the only things that matter. Then he might see Sasuke as a rival to be eliminated and Sakura as an obstacle or collateral damage in his path to achieving his goals.
One possible reason could be a sudden and extreme corruption of Naruto's character. Maybe he is influenced by some dark and powerful force that makes him turn against his friends. Another reason might be a misinterpretation of a prophecy or some kind of mind - control situation.
Perhaps in a fanfiction where the world has been completely turned upside down. If Sasuke had been tricked into becoming an unstoppable villain who was about to destroy the entire ninja world, and Sakura was somehow aiding him (maybe under a genjutsu), Naruto might feel he had no choice but to stop them by killing. Another reason could be a broken heart. If Naruto loved Sakura deeply but she constantly rejected him and chose Sasuke, and then Sasuke and Sakura betrayed him in some way, his anger and pain could lead to such a drastic act.
It could be because of a dark power corrupting Sasuke. Maybe an ancient evil force takes over him and makes him see Sakura as an enemy. In some fanfics, this kind of external influence can completely change a character's actions. Also, it might be related to Sasuke's pursuit of power. If he believes Sakura is standing in the way of his ultimate power - seeking goal, he could be driven to kill her.
Another reason could be a very dark and alternative interpretation of the characters. Maybe the writer has a different view of Naruto's character arc and how he could be pushed to the extreme. And they see Sakura as a character that could be sacrificed in this extreme version of Naruto's story. But this is a very far - fetched view considering the original story's development.
One possible reason could be mind control. Some dark power might take over Naruto's mind and force him to turn on Jiraiya without his own will.
Some fanfic authors might write it as a form of wish - fulfillment. They might prefer the Naruto - Sakura relationship more than the Sasuke - Sakura one. So, they create a scenario where Sakura turns to Naruto in a romantic way. Additionally, it could be a way to explore the characters' personalities further. For example, how Sasuke would handle being betrayed and how Naruto would deal with being involved in such a situation. It gives a chance to dig deeper into their emotional and moral aspects.
In such a fanfic, one possible reason could be Naruto's feeling of being left out. Maybe he sees Sakura's constant focus on Sasuke and feels neglected in their friendship triangle. Another reason might be jealousy. If Naruto has unrequited feelings for Sakura, seeing her love for Sasuke could turn to hatred over time.
It could be due to a dark influence. Suppose she was under the influence of some dark magic or an evil force that made her lose her true self and turned her against Naruto. This could lead to her almost killing him in the fanfiction.
One possible motive could be that Sasuke is so consumed by his thirst for power and revenge that he sees Sakura as a liability or a distraction. He might think that she would try to stop him from leaving the Leaf Village to pursue his own dark path, and in his warped state of mind, decides to eliminate her.
One reason could be to create a lot of angst. If Sasuke cheats, it would deeply hurt Naruto and cause a rift in their relationship, which could lead to a lot of emotional turmoil for both characters. This would make for a very dramatic story.