Perhaps it's because Harry sees the unfairness in how others treat Luna. He has a strong sense of right and wrong, and when he witnesses Luna being bullied or misjudged, he feels compelled to step in and defend her.
It might also be related to Harry's own experiences of being an outcast at times. He can relate to Luna on some level, and defending her is also a way for him to stand up against the kind of prejudice that he himself has faced.
One reason could be their friendship. Harry values Luna as a friend and doesn't want to see her hurt.
They could become very close friends. After the war, they both have a shared understanding of the trauma and changes they've been through. They might support each other in rebuilding their lives at Hogwarts or in the wizarding world in general.
In fanfiction, their kiss might be a way to break free from the expectations placed on them. Harry is always seen as the hero and Draco as the villain's sidekick. By kissing, they are defying those roles and expectations. It could also be a way to gain power over each other in a different sense. Instead of the usual power struggle based on magic or family name, the kiss becomes a new form of power dynamic between them.
One reason could be to explore the darker side of human nature. Even though Harry is a hero in the original series, fanfiction writers might want to see how he would be affected if he was pushed to his limits. Another reason is to create a more complex and controversial storyline. It grabs readers' attention as it goes against the normal perception of Harry.
One possible reason could be a misdirected spell during a battle. In the heat of a fight, Harry's spell could go awry and accidentally kill Malfoy. Another reason might be if Malfoy was under the control of a dark wizard and was about to do something truly terrible, and Harry had to stop him at all costs, including taking his life.
Perhaps the story is set in an alternate universe where Harry has different abilities or personality traits. For instance, he might be more of a loner or less interested in leading groups in this version, so he doesn't lead the DA.
One reason could be that the fanfiction is set in a different universe where the characters' personalities are slightly altered. So, this 'new' Harry just doesn't click with Ginny in that version. For instance, if the fanfic is a darker take on the story, Harry might be more jaded and not open to a relationship with Ginny.
One reason could be a falling - out with his friends in Gryffindor. Maybe there was a misunderstanding that grew so large that he felt he couldn't stay. Another possibility is that he might be lured away by some mysterious force or character who convinces him that Gryffindor is no longer the right place for him. For example, if a new group claims to have a better way to fight Voldemort and they are from a different 'house' in this fanfiction concept.
Maybe some fanfiction authors just like to explore extremely dark and unexpected scenarios. They want to break the traditional image of the characters to create a unique and controversial story.
Perhaps in the 'harry hates dunbledore fanfiction', Dumbledore is shown as being involved in some sort of secret plot that goes against Harry's values. For example, if Dumbledore was secretly working with the dark side in the fanfiction, Harry would naturally hate him. Also, it could be that Harry has discovered some long - hidden truth about Dumbledore that completely changes his view of him, like a past misdeed that Dumbledore has covered up.
One reason could be the alteration of McGonagall's personality. If in fanfiction she is made to be overly strict or mean, Harry, who knows her real character, would dislike this new version. In the original series, McGonagall was strict but fair, and any deviation from that in fanfiction might be off - putting to Harry.