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.
It could also be that Sasuke is trying to sever all emotional ties. Sakura represents the last bit of his connection to the Leaf Village and his former life. By killing her, he is symbolically cutting off that part of himself completely, making it easier for him to fully embrace his new, darker self and leave the village without any hesitation or second thoughts.
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.
One possible motive could be that Sakura is brainwashed. Maybe an enemy uses some kind of mind - control jutsu on her and she becomes a puppet to kill Sasuke. Another could be extreme jealousy. If she felt that Sasuke was slipping away from her in some way, in a very dark and twisted version of the story, it could lead to her killing him.
A possible motive could be a creative exploration of the 'what - if' scenarios. Maybe the writer wants to see how the story would unfold if Sasuke completely lost his way. Another motive could be to create a sense of high - stakes drama. Since Sakura is an important character, her death at Sasuke's hands would be a huge shock.
One possible motive could be power. In some fanfics, Sasuke might be driven by an insatiable thirst for power and see Naruto as an obstacle. Another could be revenge, perhaps believing Naruto has wronged him in some way in that alternate story. Or it could be a matter of being corrupted by dark forces, which make him turn against Naruto.
One possible motive could be a dark magic or mind - control situation. Maybe an enemy has the power to control Naruto's actions and forces him to kill Sasuke against his will. Another could be a miscommunication where Naruto believes Sasuke has done something unforgivable, like harming the village in a way that Naruto can't overlook.
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.
Kakashi would be deeply affected. He has mentored both Sasuke and Sakura. This would make him question his own teachings and his ability to protect his students. He might also feel a sense of responsibility and could become more involved in trying to bring Sasuke to justice or at least understand what drove him to such an extreme 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.
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.
Perhaps Sasuke was testing Sakura's loyalty or strength. He may have thought that if she couldn't withstand his aggression, she wasn't worthy of being in his life. Also, his own inner demons, like the hatred he carried from his past, could have flared up and led him to almost kill her without fully realizing what he was doing.