What happens to John at this point in the book is that he completely loses his head and, because of it, he will soon lose his life.
When the crowd starts to imitate him, they get caught up in a frenzy. For them, the only kind of frenzy that is familiar is the "orgy-porgy" sexual frenzy. So that is what they do. John is already quite emotionally charged and in something of a frenzy himself. So it is not surprising that he loses control and participates in the orgy.
This leads to him killing himself out of shame.