There are several possible reasons. Maybe Harry discovers a powerful and dangerous magical artifact and starts toying with it without proper guidance, which Dumbledore sees as a huge risk. Or perhaps Harry spreads rumors or secrets that Dumbledore has entrusted to him, and Dumbledore feels the need to discipline him to protect the safety and stability of Hogwarts. Fanfic authors often use such situations to show the complex relationship between Dumbledore and Harry and how they navigate through difficulties.
One possible reason could be if Harry were to break a major school rule in the fanfic, like using dark magic without proper authorization. Dumbledore is a strict adherent to the rules of Hogwarts and would likely punish such behavior.
One possible reason could be that Harry breaks school rules in the fanfiction. For example, if he ventures into the Forbidden Forest without permission. Dumbledore is strict about the safety of students and such disobedience might lead to punishment.
Perhaps in the fanfic, there's a new plot device introduced. Maybe a dark magic influence has made Harry believe that Dumbledore is actually working against the greater good. This could be a new evil spell or a manipulative character who has poisoned Harry's mind against Dumbledore.
It could be that Harry finds out about Dumbledore's secrets regarding the Deathly Hallows. If Harry thinks Dumbledore was more interested in the Hallows for his own purposes rather than for the greater good, it might make him hate Dumbledore.
Perhaps in the fanfic, Harry discovers that Dumbledore has been manipulating him all along. Dumbledore has always been a very complex character with many secrets. If Harry were to find out that Dumbledore was using him as a pawn in a much larger and dangerous game, his anger could lead him to punch Dumbledore. This would completely change the dynamic between them and open up a whole new set of storylines and character developments.
One possible reason could be that Dumbledore believes he is acting in Harry's greater good. Maybe he thinks that by taking certain items from Harry, he can protect them from falling into the wrong hands. For example, if Harry has a powerful magical artifact that Voldemort desires, Dumbledore might steal it to keep it safe.
One possible reason could be a misunderstanding. Maybe Harry is led to believe that Dumbledore has been hiding something crucial about his parents' death or Voldemort's return. For example, if Harry discovers some encrypted files in Dumbledore's office that seem to suggest Dumbledore had a prior deal with Voldemort, it could lead to a fight. Another aspect could be related to power. If Harry feels that Dumbledore is being too controlling over his actions and the use of his powers, he might lash out. In the wizarding world, power struggles are not uncommon, and Harry, as a powerful wizard in his own right, might want to assert his independence.
One possible reason could be a miscommunication. Maybe some evidence is misinterpreted, and Dumbledore thinks Hermione has broken a major rule. For example, if he thought she was involved in some dangerous magic experiments without permission. But this is a hasty conclusion for him to make.
In some fanfics, Snape might punish Harry because of his perceived insolence in class. Harry has a rebellious streak, and Snape, being strict, wouldn't tolerate any behavior that he deems disrespectful to his authority as a teacher.
Perhaps there are safety concerns for the students that Dumbledore is not addressing adequately. Harry, having a strong sense of responsibility for his fellow students, may feel that the only way to ensure their safety is to remove Dumbledore from his position. He might believe that Dumbledore's actions or inactions are putting the students at risk, and thus he takes matters into his own hands.