One of the reasons that there is such a large number of mammal species in the world is that many of them are restricted to relatively small areas. There are a great many species that can be found only in one place, perhaps because it's a remote island or otherwise physically difficult to leave, or perhaps because they have very specific requirements and can't traverse the terrain between the patches of land that meet them. Others, of course, may have lived across wider areas in the past, but are now endangered, perhaps because their land has been converted to agriculture or urban areas, or because they are seen as either especially tasty or a threat to humans or their crops.
On the other hand, many species are widespread with large populations and seem to be happy in a variety of different habitats. Often, these are animals with a broad diet, able to eat a range of different foods and still remain healthy - the red fox is a good example of this, especially once it started exploiting suburban habitats in the 20th century. Typically, they will not be as good at finding or processing these foods as those that specialise in one particular type but the fact that they can switch food sources easily makes up for this. Indeed, this can be a driver for evolution - an animal becomes really good at exploiting one narrow food source, out-competing the generalists, but the latter remain in the background and, when the world changes and the narrow food source is replaced by something different, become the basic stock from which the next round of specialists will arise.