They aren't replicating things in the holodeck (though food/drink might be a special case, as well as smells), it uses holograms and force fields to simulate what is seen, heard, and touched. Taste/smell would depend on how fine the holodeck's control is, as that's not just a touch-based thing, but touch with a specific chemical interaction between our cells and the substance touching them. The holodeck would either need to fake that interaction or fake the signal in our brains telling us what that interaction felt like.
The safety protocols are likely just rules on how much a hologram (or rather the force field making it feel real) can enter your personal space (it's fine to press a bit on skin but you don't want to pierce into it), how much force can be used to interact with you or subject your body to, probably rules about those chemical interactions (if the holodeck is capable of simulating those) or what chemicals it will replicate (if that's the mechanism it handles taste/smell with), and acceptable environmental parameters like pressure and temperature.
I wonder if realistic holodeck safety protocols even allow for sex. Not because I think they are prudes but just thinking about how to simulate sex using holographs and force fields makes it seem risky to do at all. Like how would one determine the exact position of the skin in contact to be sure it feels pleasurable and doesn't do things like getting too close and pinching parts it is supposed to just rub up against. The sensor array that would require might be unrealistic on its own, let alone the processing you'd need to do to handle that in real time.