How do scientists know how many galaxies there are in the universe?
Astronomers assume the cosmological principle: The universe is homogenous and isotropic. In plain words, it looks the same in all places and all directions. This principle has been shown to be true, so far.
There is no reason to think there is a preferred position in the universe, or a preferred direction in which forces would act more strongly. This intuition comes from the symmetry of physical laws, a quite interesting topic on its own.
Regardless, Astronomers make the assumption that on the largest scales (tens of millions of light years), the Universe looks (statistically) the same. Based on our samples in several directions, we can count a certain number of galaxies and we just extrapolate this to the rest of the Universe. One project that helps both affirm the Cosmological Principle and count galaxies is the Sloan Digital Sky Survey, SDSS, which is a survey counting galaxies in the sky. It's not complete but it does make some nice plots of the near and not so near universe.
Here's an image compiled with SDSS. Note that the empty regions are the blind spots of the telescope, it can't see the entire celestial sphere as it's not in space.