I *finally* looked up why prostitution is illegal but acting in porn isn't, in the USA, and apparently it's mostly due to the First Amendment. Seems... off. Have they never heard of performance art? IDK, I think the law is backward in these areas, but at least it's trying to protect people from the dangers of prostitution. Though I bet legalizing would be safer for everyone involved, nowadays.
It's because you're not paying someone to have sex with you, you're paying people to film them having sex. Technically, production is only explicitly legal in California (where a badly-worded bill intended to kill the industry legalized it instead) and New Hampshire (thanks to that whole "Live free or die" thing they have out there), but the few attempts at prosecution elsewhere have failed due to that technicality.
It is distribution that is protected under the First Amendment, not production.
More interesting is that pornography is a perfect example of an industry that is literally being gutted by piracy. Despite vastly increasing acceptance of it as normal and skyrocketing amounts consumed, profits are plummeting because most of the distribution is via *tube sites and torrent. Attempts by activists to kill it, often with documentaries filled with blatant lies, don't help (particularly since the industry has a significant lack of effective libel protection no matter what the law says), but declining incomes are a provable fact.