If other animals have more than 2 nipples, then why do humans have only 2 nipples?
Even my pet dog has more than 2 nipples.
Questions of the type, "why does organism X have feature A?" invite teleological (just so) explanations which are difficult to substantiate. For example, the number of teats on a cow are difficult to explain in terms of providing milk to humans!
We should look to evolutionary history to explain human traits, not "just so" stories. The simple answer is that humans are primates, and primates have similar bodies and lifestyles. If there's a single pressure that lead to the number of teats in primates, it's likely the arboreal niche, not the mean litter size. Indeed, litter size is usually a plastic trait, even in primates, and is certainly not an accurate predictor of the number of teats.
There are no strict restrictions on nipple numbers in humans; they can occur anywhere on the milk line. So humans tend to have two nipples because that's what primates tend to have, because of our evolutionary history.
A better answer than this one would locate a candidate common ancestor to the primate and non-primate lineages and make reference to the embryonic development of the mammary tissue.
Your pet dog needs more than two nipples because she can have up to 11 or more puppies. If she had two nipples, most of them sound starve.
Twins are rare enough in humans. Two nipples are fine, and fit with bilateral symmetry. All primates have two nipples. So do many animals with one, two, and rarely three offspring at a time. Elephants: 2 teats, 1 calf (usually). Goats: 2 teats, 2 kids.
Why a cow has four teats, I'm sure I don't know, but I'm sure that's what made them valuable as a milk source to man.