A legitimate question. Let us deal with the matter as scientists.
A combination of things is involved. The answer lies in large part in the digestive tract itself. In animals such as rabbits, the feces are formed into pellets by the colon, which pushes them out into the rectum rhythmically, leading to a fairly uniform shape and size. Of course, the rectum also plays a role. Some animals have internal muscles that control the process to a degree, such that each fewmet comes out virtually the same size and shape—essentially, the rectum acts a lot like a press (maybe a better analogy would be a sausage-making machine). Caterpillars, which lack a colon or sphincter, derive the shape of their droppings entirely from the rectum, while the dropping shapes of animals such as goats, deer, and rabbits are due to a combination. Horse apples are not quite as consistent, but they’re close. When the feces are more amorphous, only the anal sphincter contributes to the shape; if the sphincter stays open a long time, you tend to get long, unbroken masses, as in humans. The phenomenon doesn’t correlate strictly with a fibrous diet (though the pellets would probably not hold their shape otherwise), since animals like cows and buffaloes have a fibrous diet but most definitely have soupy poop. Obviously, the digestive process itself—which is different in ruminants such as cattle—is also a factor.