The main reason for the digestive system to vary in length from one mammal species to the next is the animal's diet. More specifically, an animal that eats a diet that has a lot of calorie-dense foods will have a shorter digestive tract than an animal that eats a diet that is primarily fibrous.
Meat and fat are calorie dense, and can be broken down rapidly, so carnivores usually have a digestive tract that is quite short in proportion to their body size. Plant foods are not as calorie dense, so an herbivore has to eat more pounds of food to get the same number of calories as a carnivore; in these animals the digestive tract is proportionally longer so the animal can digestive larger batches of food at a time.
Contrary to the statement made in the previous post, cows and other ruminants do not have several stomachs, they have just one stomach. However this stomach is divided into several pouch-like regions where fermentation occurs. All mammals have difficulty breaking down plant fibers, but ruminants have a population of specialized intestinal bacteria which can assist them with this task, allowing them to absorb calories from plant fibers which would otherwise be indigestible. However this process is slow and inefficient, so they must eat a lot of material in order to extract sufficient calories to stay alive.
The length of the intestinal tract varies in different animal species because the species themselves varry. The size of the animal is one contributing factor in the length of the intestinal tract. The intestinal tract of a blue whale certainly wouldn't fit inside the abdominal cavity of a human and certainly not in a smaller animal like a cat. The diet of the animal also makes a difference in how many of the internal organs function including the intestinal tract. An herbivore will process food differently than a carnivore or an omnivore. Some diets take more time and more work for the body to digest. A longer intestinal tract will allow more times and space for nutrients to be extracted from the food materials. Animals with a more complex diet are likely to have a longer intestinal tract. It is the same principle that affects other organs as well. For instance, a cow has several stomachs. Grass and grain are difficult for the cow to digest so the animal has adapted to include several stomachs in the digestion process in order to extract all the essential nutrients from its food.