It could be that Snape has just uncovered one of Harry's secrets. Harry might be afraid of the consequences. Snape is known for his strictness and sometimes harsh treatment of students. If Harry has made a mistake or is involved in something dangerous, and Snape has found out, Harry could be so worried and scared that he cries. For example, if it has something to do with the Dark Arts or endangering Hogwarts.
Maybe Harry is under a great deal of stress. He has so many burdens on his young shoulders, like fighting Voldemort, protecting his friends, and dealing with the secrets of his past. Snape has always been a rather intimidating figure to him, but in that moment, the pressure might just be too much, causing him to break down in front of Snape.
Perhaps there is a misunderstanding. Snape might have wrongly accused Harry of something. Harry, feeling unjustly treated and frustrated, might break down in tears. He has always tried to do the right thing, but Snape's suspicions and accusations could be too much for him to bear at that moment.
Snape could be initially shocked. He's used to seeing Harry as a rather tough and rebellious student. So, seeing Harry cry might take him aback for a moment. Then he might become a bit more guarded and try to figure out if Harry is faking it or not.
One reason could be the stress of fighting Voldemort. Harry has so much on his shoulders, and McGonagall is a figure of authority and comfort. He might break down in front of her when the pressure becomes too much. For example, when he has to face difficult decisions like whether to sacrifice himself or when he feels responsible for the safety of his friends.
In some fanfics, Snape might punish Harry because of his perceived insolence in class. Harry has a rebellious streak, and Snape, being strict, wouldn't tolerate any behavior that he deems disrespectful to his authority as a teacher.
One reason could be to save him. Maybe Harry is injured during a battle or some sort of magical accident, and Snape, despite their differences, steps in to carry him to safety. For example, if Harry is hit by a dark curse and Snape, with his knowledge of dark magic, knows he needs to get Harry to the infirmary quickly.
Snape might be initially taken aback. He could hide his surprise behind his usual stern facade and perhaps try to maintain order, but secretly be a bit worried.
One reason could be that Harry is under an extreme amount of stress. He has so many burdens on his shoulders in the wizarding world, like fighting Voldemort. This stress could manifest physically as a seizure, especially if he is in a tense situation in front of Snape, who is often a source of anxiety for him. For example, if Snape is about to accuse him of something he didn't do while he is already worried about other threats to the wizarding world.
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.
One possible reason could be that Harry breaks a major rule in the wizarding world within the fanfic. Snape, being a strict and by - the - book person, grounds him as a form of punishment. For example, if Harry uses dark magic without permission, Snape would surely take strict action.
Maybe in the fanfic, Snape is written as having some hidden, truly evil motives that Harry discovers, leading him to kill Snape. For example, if Snape was secretly working for a new dark force even worse than Voldemort.
In some fanfictions, Snape might awkwardly try to comfort Harry. Given his own complex personality, it wouldn't be an easy or natural gesture for him. He might pat Harry's shoulder stiffly or offer some gruff words of reassurance like 'Pull yourself together, Potter.'