T. Rex was a predator, however, and an apex predator at that. Elephants are herbivores. That changes the expected numbers quite a bit. Prey populations typically outnumber their predators by two to three orders of magnitude.
1. Water covers ~70% of the Earth's surface. Whales migrate of course but can exist from the poles to the equator;
2. Of the 30% land, for pretty much any species, some portion of that is uninhabitable. Dinosaurs being reptiles likely require hot and wet environments. As predators, T. Rex would be limited by where their food could live too.
The dinosaur era was largely one of a super-continent (Pangaea). A good portion of that was likely too cold or too dry to support such a large predator.
They lived in what is now Western North America, but was then an island continent called Laramidia [1] so yes, they were geographically quite limited.