Well, there is no telling what is going on until everyone comes clean.
Your GF may have been 'with him' before, or before you....
He's a man, and being a man, it is hard to turn down a fuck....and sometimes the adventure of the taboo brings a certain thrill. This is not uncommon.
Still, I can see that it has shocked and bewildered you.
If you want to understand, you have to talk to her and him...do a favor to your future self by keeping your hands to yourself, and playing it cool until you get enough of the truth...then walk away and think it over...likely to just walk on.
It may not work, since the beating may have intimidated both of them.
You sound like a person who lives by rules, rather than desire and impulse, would that be right ? If so, you are clearly NOT the same type as your GF, IMJ.
Wonder what your mom thinks of all this ? ...if she knows.