Carrots probably work this way (amongst other reasons) because of their high fiber content.
In fact carrot juices contain certain oils that work on the mucus membranes of the stomach and colon. This helps with digestion and starts your bowels functioning properly.
Carrots can also make your stools softer and larger & therefore better this way because larger stools dilute toxins, expose less toxins to colon walls, and press against colon walls to promote peristaltic action.