Why do some herbivores like sheep, cow, and others excrete feces in a pellet (or biscuit or other) shape, while other species including humans do not do so? What is the reason for such an adaptation in herbivores? Is it beneficial to them, and if so, how?
I don't think it is an adaption, but the that diet plays a dominant role. The feces of cows in intensively fertilized agricultural fields, with grasses rich in protein, has no shape at all. See picture below.
The feces of cows in natural areas has much more structure. (image has copyright, so can only link)