Think of your rectum like the mouth of a drawstring bag. It’s pulled closed by default, and unless something prompts it to open by going out or coming in, it stays that way.
In other words, the valve is closed in the bathtub unless you open it.
You have a sphincter. It’s a round muscle that tightens to keep fluids in (or out). It’s the same muscle at the bottom of your esophagus, keeping your food in your stomach.
Next time you’re in the bath tub, reach down there and figure it out.