Maybe he was poisoned. There could be someone who slipped a harmful potion ingredient into his cauldron without him noticing. It's a common plot device in fanfics to create drama.
Perhaps there was some sort of magical interference. Another student might have accidentally (or on purpose) cast a spell near his cauldron that disrupted the potion - making process. This disruption could have released some sort of negative magical energy that affected Harry, causing him to collapse. It could also be related to a pre - existing condition that was exacerbated by the fumes or the magical properties of the potions ingredients he was using.
It could be Malfoy. He often has a vendetta against Harry and might have found a way to make him collapse during potions class, either by tampering with his ingredients or distracting him in a way that leads to a mistake in the potion - making process.
Maybe Snape wants to train Harry better. By using potions to change Harry's abilities or characteristics, he can expose Harry to different challenges and make him a stronger wizard. For instance, if he gives Harry a potion that temporarily takes away his ability to use magic, Harry will have to learn to rely on other skills.
One reason could be that he's facing extreme pressure in potions class. Maybe he's constantly compared to others, like Snape always having high expectations of him. Another reason might be that he has some kind of emotional turmoil related to his past traumas while in the potions environment. For example, the smell of a certain potion might remind him of a difficult time at the Dursleys.
It could be that he has a bad accident in the potions lab. For example, a potion explodes and nearly kills him or one of his friends. This traumatic experience makes him lose his confidence and interest in potions, leading him to quit as seen in some fanfictions.
One possible reason could be overexertion. Maybe he was using too much magic outside of class and it drained him. Another reason might be some sort of magical illness or curse that he's been secretly dealing with.
One possibility is that a potions accident could cause a time - related mishap. Maybe the potion was supposed to be a simple Sleeping Draught but due to the accident, it creates a time - loop. The characters find themselves repeating the same day over and over until they figure out how to reverse the effects of the botched potion. This could be a really interesting plot device in a Harry Potter fanfic as it would allow for a lot of character development and exploration of different choices within the same day.
In a lot of these fanfictions, it could be that Harry has a secret mentor. This could be an old wizard who has been secretly guiding Harry in potions, away from the prying eyes of the Hogwarts staff. This mentor could have seen Harry's potential early on and decided to help him develop his skills in private. Another aspect could be that Harry's own determination and his need to prove himself in a different area other than Quidditch or fighting Voldemort drives him to secretly practice and become good at potions. Also, the idea that there are hidden aspects of magic within him, perhaps related to the founders of Hogwarts, that only manifest in his potions - making ability.
In some fanfiction scenarios, Peter might be dealing with some sort of internal power struggle. If his spider - powers are evolving or being affected in some way, it could lead to his collapse at school. For instance, if there's a glitch in his powers that causes his body to have sudden energy drains or physical reactions, like collapsing, while he's at school trying to act normal.
It could also be due to physical exhaustion. Caroline might have been overexerting herself in trying to fight against Klaus' enemies or protect her friends. She could have been running on fumes for a while, and when she finally saw Klaus, her body just gave out from sheer fatigue.
Perhaps he was extremely tired or stressed. Harry has a lot on his plate, with Voldemort constantly being a threat and all the schoolwork and Quidditch. He might not have had enough sleep or rest, and the potions class was just the tipping point where his body gave out.