One possible reason could be extreme jealousy. Sakura might be so blindly in love with Sasuke that she sees Naruto as a threat to Sasuke's attention or her relationship with Sasuke. Maybe she thinks Naruto is getting in the way of Sasuke's return to the village or her attempts to win Sasuke back.
One possible reason could be a misunderstanding. Maybe Naruto misinterprets some of Sasuke and Sakura's actions as being against him or the village. For example, Sasuke's quest for power might seem like a threat to Naruto, and he could misread Sakura's loyalty to Sasuke as a form of betrayal to their friendship.
One possible motive could be mind control. Maybe an enemy uses some kind of jutsu to make Naruto lose control and attack Sakura. Another could be a misunderstanding. For example, if Sakura was framed for something really bad, and Naruto in his hot - headedness believes it and attacks her. Or perhaps in a dark, alternate universe version of the Naruto world where the characters' personalities are twisted, Naruto might have a reason to attack her based on that altered personality.
He may also choose to defend himself without really fighting back. Naruto values Sakura as a friend and teammate, so he would be reluctant to harm her. He might just try to dodge her attacks and keep talking to her, hoping to snap her out of it.
Perhaps there was some sort of dark influence at play. In the world of Naruto, there are often dark forces and genjutsu (illusion techniques). It's possible that Naruto was under the influence of a genjutsu that made him see Sakura as a threat, so he punched her in self - defense without realizing it was an illusion.
One possible reason could be jealousy. Maybe in the fanfiction, Naruto feels overshadowed by Sasuke in Sakura's eyes, which leads to his hatred. Another reason might be that he perceives their relationship as a threat to his own bonds with them. For example, he could think that Sasuke and Sakura's closeness excludes him in some way.
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.
In a fanfic, it could be for comedic purposes as well. The idea of Sasuke trying to act like Sakura while tricking Naruto can lead to some really funny situations. Maybe Sasuke is forced into this by some strange situation or magic. And he has to keep up the act of being Sakura, which includes mimicking her mannerisms and speech patterns, all while trying to fool Naruto. This could create a lot of humorous misunderstandings and interactions within the story.
One possible reason could be that Sakura realizes she has different goals or values that are not compatible with being around Naruto. Maybe she discovers a new path in life that doesn't involve him, such as focusing on her own medical ninja career without Naruto's chaotic lifestyle interfering.
It could also be related to Sakura's strength. Sasuke is constantly striving to become stronger. If Sakura somehow shows a weakness or makes a mistake during a fight that he thinks could have been avoided, and it has negative consequences for their situation, he might get angry at her for not being more capable.
One possible reason could be a misunderstanding. Maybe she was misled by false information about Naruto being a threat to the village. Another reason might be that she was under some kind of mind control. In some fanfictions, dark magic or evil entities can take over a character's mind and make them act out of character.