Well, it could be that in these fanfictions, a dark influence overcomes Hermione and Ron. They might be manipulated by a powerful dark wizard who makes them believe that betraying Harry is the right thing to do. It could also be a miscommunication situation where they think they are helping but end up betraying Harry. For instance, they might be tricked into believing that Harry has turned bad and needs to be stopped.
Some fanfictions play with the idea of character flaws. Hermione's intelligence and Ron's insecurities could be twisted in such a way that they betray Harry. Hermione might think her intellectual superiority gives her the right to make decisions for Harry, even if it means going against him. And Ron, with his envy sometimes, could be lured into actions that seem like betrayal. This creates a really interesting and often heart - breaking twist to the original story.