I have a hard time believing there are that many planets that are "exactly" like Earth.
Why settle for less?
I mean, there's no need to settle for what nature provides. Star Trek assumes the existence of civilizations, and those will have an incentive to engineer the planets to their liking. And all we need then is a single dominant civilization at some specific era: all later civilizations will thrive if they survive on the type of planet preferred by that once-dominant civilization, and will terraform even more planets to that standard - and will remain second-rate if they are incompatible.
Eventually, all planets that somewhat resemble Earth will be exactly
like Earth. Even planets that are quite unlike Earth (such as the one from "Paradise Syndrome") will be engineered to be exactly like Earth, although the terraforming in those cases may wear off in an aeon or two.