It could also be due to a choice Harry makes that his friends don't agree with. Suppose Harry decides to take on a very dangerous mission alone to protect his friends, but they see it as him not trusting them. This could lead to a rift and eventually him losing their friendship.
Another reason might be jealousy. If Harry suddenly gains more power or attention in the fanfiction world, his friends could become jealous. For example, if he discovers a new and powerful magic spell, and all the focus in the magical community is on him, his friends might start to feel overshadowed and distance themselves from him.
One possible reason could be to protect them. In many fanfictions, Harry might believe that by distancing himself from his friends, he can keep them out of danger. For example, if there is a new dark threat targeting him specifically, he may think that the enemy will use his friends against him.
Maybe his friends betrayed his secrets. In many fanfictions, a friend might accidentally or deliberately let out something Harry had confided in them, like his fears about Voldemort or his feelings for a certain girl. This could shatter his trust.
One possible reason could be that he's constantly being underestimated or not given the credit he deserves. In some fanfictions, his friends might take his contributions for granted, which could lead to his temper flaring up.
One reason could be to escape the lingering dark magic and the constant reminders of their past battles. Britain, especially Hogwarts, has seen so much turmoil that they might feel the need for a fresh start. Another reason could be to explore the wider wizarding world. They've been mostly centered around Britain in the original stories, and in fanfiction, they could leave to discover new magical cultures and spells in other parts of the world.
Perhaps he is betrayed by those he trusts. In the original series, there were instances of betrayal, and if in the fanfiction this is amplified, for example, if the whole wizarding community turns against him unjustly. He might feel so alone and hopeless that he loses his will to live. Also, if he discovers some dark secrets about his past that make him question his own identity and worth, it could lead to this state.
One possible reason could be jealousy. Maybe Harry has achieved something great and his friends can't handle his success. For example, if he gets a very important role in a magical competition, his friends might feel overshadowed. Another reason could be a misunderstanding. Harry might be wrongly accused of something, like being in league with the dark side, and his friends, in their fear or haste, abandon him without giving him a chance to explain.
One reason could be a misunderstanding. Maybe there was a miscommunication between Harry and his friends, and he felt so hurt or angry that he decided to leave. For example, if his friends wrongly accused him of something he didn't do.
In this fanfiction, it could be that the pressure of being 'The Chosen One' finally gets to Harry. All the battles, the losses he has endured, and the constant threat of Voldemort might push him over the edge. He could start acting erratically, pushing away his friends and allies because he no longer trusts his own judgment.
Well, in the 'Harry Potter loses his magic fanfiction', he could end up finding new strengths within himself. Maybe he discovers that his courage and intelligence are enough to get him through tough situations even without magic. He could also start to see the wizarding world from a different perspective, one of the non - magical people, and perhaps work towards making the two worlds more inclusive.