I do think religion has contributed to the shaming of non paired sexual behaviors, but I think its origins run much deeper and closer to social realities...beyond what any sort of "God" would say about it there are specific, privilege and advantage seeking reasons, probably formed in our primate-to-hominid prehistory, why either gender would have an issue with the other engaging in sexual activity outside of their particular pairing.
I can't argue with the reality of what religious socialization has done to women and men. It's been entrenched worldwide for millennia. Despite the advantages it gives its influence is still sexist limiting both women and men to specific roles. It is changing slowly but unlikely to end soon.
It's clear why a male would have an issue with a female mate having sex outside their pair bond: he doesn't want to raise another male's offspring and he doesn't want to lose his pair bond with her to another male (or female).
It's clear why a female would have an issue with a male mate having sex outside their pair bond: she doesn't want him to have offspring with another female and she doesn't want to lose her pair bond with him to another female (or male).
As for our prehistory as hominids what we see in human morphology today are males who are on average 30% larger and stronger than females. This reflects a time in the past where our species didn't form one-on-one pair bonds. Instead we were a tournament species where males had harems of females. Having to fight off all other males selected for the largest and strongest males making them much larger than females.
We see this in other primates today. Gorillas are a tournament species. Males have harems of females--or many wives if you prefer. Because they have to fight for this male gorillas have much larger and stronger bodies than females. On average 5% or less of tournament species males pass their DNA along.
On the other hand female and male chimps are the same size. While they don't form one-on-one pair bonds the males aren't forced to fight to mate. When a female chimp goes into estrus all the males in the troop mate with her. No one knows who the father is but it doesn't matter because they all live together and support each other as a troop. Everyone gets the chance to pass their DNA along.
In evolutionary terms our species is stuck somewhere between a tournament species and a pair bond species. We still see plenty of male-on-male violence over females to get a mate and male-on-female violence to maintain a mate. But we also share pair bond adaptations with chimps like specialty sperm which recognizes and fights the sperm of other males. This suggests strongly that sometime in our hominid past males either had harems or that multiple males mated with females or both.
What it means for us today is that humans don't instinctively form one-on-one pair bonds. Thus socialization which ostracizes anything but a lifetime heteronormative pair bond rules the vast majority of human cultures. There are polygamous exceptions of polyandry and polygyny but they are relatively rare as is the groupie phenomenon of large numbers of females selecting and bedding a few high status males.