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.
Another reason could be related to Harry's interactions with other students. If he gets into a fight or bullies another student, Dumbledore would surely step in and punish him. Dumbledore aims to maintain a harmonious and safe environment at Hogwarts, and any behavior that disrupts that would not be overlooked.
He might give Harry detention. Harry could be made to clean the trophies in the trophy room or help Hagrid with some difficult tasks in the Forbidden Forest under strict supervision.
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.
Sexual fanfiction involving Harry Potter is inappropriate in the first place as it goes against the intended nature of the series. Dumbledore, as a moral figure in the original story, would likely be seen as acting in an ethical way to punish behavior that distorts the essence of the story and its characters. However, this is all within the realm of fanfiction which is not part of the official canon.
One possible reason could be a misunderstanding. Maybe Harry overheard something that made him think Dumbledore was planning something against him that he didn't understand. For example, if he heard Dumbledore discussing a dangerous mission for him without his full knowledge.
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.
Maybe Harry finds out that Dumbledore knew more about his family's past than he let on. For instance, if Dumbledore had information about some dark secrets in the Potter family but didn't tell Harry, it could make Harry furious and prompt him to yell. Also, if Dumbledore's actions led to the death or harm of someone Harry cared about, like Sirius, Harry would likely be very angry with him.
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.
Well, Harry might outsmart Dumbledore by using his unique understanding of the magical world in ways Dumbledore doesn't expect. For example, Harry has a more direct experience with some dark magic items due to his encounters with Voldemort. He could use this knowledge to make decisions that seem counter - intuitive to Dumbledore but are actually more effective in a particular situation.
One possible reason could be that Harry has discovered something about himself or his past that he thinks Dumbledore might not approve of or might try to stop him from exploring further. For example, if he found out some dark magic connection in his family history that he wants to understand on his own without Dumbledore interfering.
One reason could be a difference in ideology. Harry might have come to believe that Dumbledore's methods, like keeping secrets from him, are not in the best interest of the wizarding world. For example, Dumbledore withheld information about Harry's connection to Voldemort which put Harry in more danger at times. Harry could stand up to him to demand more transparency.