Our guinea pigs do the same thing.
Any other time and they don't get so close together. In the vet's office they take turns crawling under each other.
"Mounting" is dominance behavior among guinea pigs regardless of sex. If a guinea pig climbs on top of another one, it's saying, "I'm the boss". So it's kind of amusing in a sad way to see the behavior change from trying to establish dominance to trying to force the other one to establish dominance.
"You're the boss!"
"No, you're the boss!"
In an excellent example of the lengths a cat will go to in order to fuck up your day, one of my cats jumped up to the top of the post at the top of the stairs and puked down the side of the post from his perch.
It was honestly impressive in a what-kind-of-sociopath-would-do-that way.