Think about this for a moment: Prostitution is illegal, but making porn movies is not.
You can't legally pay someone to have sex with you, but you can pay someone to have sex with someone else and film it. You can legally pay someone to have sex with you if you film it, because in that instance, you're not paying them for sex. You're paying them for 'acting'.
Thanks to defective yeti for bringing this up.