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.
If Harry were to endanger the safety of other students in the fanfic, Dumbledore would surely punish him. For example, if he led his friends into a dangerous situation in the Forbidden Forest without permission, Dumbledore would have to take action to ensure the safety of all students.
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 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.
Maybe Dumbledore discovers some dark secret about Harry's past that he can't handle. It could also be that Dumbledore is trying to protect Harry in a really strange way, by pushing him away from the dangerous wizarding world around Hogwarts.
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.
There are several potential reasons. If Harry were to show signs of being influenced by dark forces, Dumbledore would want to correct his path and might punish him to make him see the error. In fanfiction, perhaps Harry gets involved with a group that has questionable motives, and Dumbledore punishes him to keep him away from that. Additionally, if Harry were to neglect his studies and focus too much on other things like Quidditch or personal vendettas, Dumbledore could punish him to encourage him to balance his life better.
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 that Harry discovers some secrets about Dumbledore that make him lose trust. For example, if he finds out about Dumbledore's past mistakes or hidden agendas that he doesn't agree with. Another reason might be that Harry feels he can better protect his friends and fight Voldemort on his own terms, away from Dumbledore's influence and strategies which he may start to question.
One reason could be Harry's resemblance to his father. Snape had a long - standing grudge against James Potter, and seeing Harry might trigger those old feelings. In slash fanfiction, this can be exaggerated, with Snape being harsher on Harry because of his connection to James.