They like the carpet because it's softer like earth or grass.
I don't know your routine so I'd like to share a communication tip that may be handy.
I have a string of bells hanging on the door knob. My pup learned quickly that the door will open to let him out anytime he rings the bells.
My other fix is creating a pee-pad in an area of the house where guests won't see it by using a sheet of plastic (A large garbage bag works ) coverered with an old rag rug or a couple old folded towels and then top it with a piece of fake fur.
My fur baby has been good at using that when I'm not home to let him out. I add white vinegar to the rinse water when I launder the towels to make them smell fresher. Or -- there are "prettier" versions you can purchase that have disposable pads.
As for cleaning, there are numerous products on the market that have enzymes that will eat any of these offensive bodily fluids and help eliminate odors.
Hope this helps!