The key to understanding what's going on is that the apparent surface brightness (observed flux per unit solid angle) of galaxies at different distances depends on two main things: how many stars are packed into a given angular area on the sky (which depends on the intrinsic density of stars in the galaxy and on the distance), and how faint the individual stars become as a function of distance.
Any image will have a limiting resolution: the size of the seeing or the telescope's point spread function, the size of pixels in the camera, etc. For example, the human eye has a limiting resolution of about 1 arc minute. We can crudely talk about the surface brightness of galaxies in terms of how much stellar flux comes from an angular region (solid angle) with the size of the limiting resolution.
Let's work with a simple model: a circularly symmetric galaxy, without dust, containing identically bright stars with a radial exponential distribution. That is, the galaxy has a certain central surface density (call it $n_{0}$ stars per square kiloparsec), and that density falls off as you go away from the center with an exponential function that has a scale length of 1 kiloparsec (kpc):
$n(r) = n_{0} e^{-r}$
For a central, circular resolution element corresponding to a physical radius $R$, the total number of stars $N$ within that radius will be
$N = \int_{0}^{R} 2 \pi r n(r) dr = 2 \pi n_{0} (1 - (1 + R) e^{-R})$
Consider three cases: the first where the galaxy is only 1 kpc away from us, the second where the galaxy is 1 Mpc away from us (1000 times further away), and the third where it is 10 Mpc away.
So we're going to look at the question of how many stars are packed into the central circle with radius = 1 arc minute, and how much light we get from just those stars. When the galaxy is only 1 kpc away, the 1-arcmin-radius circle has a physical radius of $R = 0.29$ pc; for 1 and 10 Mpc away, $R = 290$ pc (0.29 kpc) and 2.9 kpc, respectively.
If we assume that stars at 1 kpc distance have an observed brightness of 1 (in whatever the appropriate units are), then the same stars at a distance of 1 Mpc will be one million times fainter, and will have individual brightnesses of $10^{-6}$; at 10 Mpc, they will have a brightness of $10^{-8}$. (This is just the inverse-square law: the same star $x$ further away will be $x^{2}$ times fainter.)
For the three cases, we have:
($D = 1$ kpc) There are $2.7 \times 10^{-7} n_{0}$ stars in the central $r = 1$ arcmin region, each with flux = 1; total flux in the central region is $2.7 \times 10^{-7} n_{0}$.
($D = 1$ Mpc) There are $0.22 n_{0}$ stars in the central $r = 1$ arcmin region, each with flux $= 10^{-6}$; total flux in the central region is $2.2 \times 10^{-7} n_{0}$.
($D = 10$ Mpc) There are $4.9 n_{0}$ stars in the central $r = 1$ arcmin region, each with flux $= 10^{-8}$; total flux in the central region is $4.9 \times 10^{-8} n_{0}$.
The precise details will depend on the actual structure of the galaxy and the intrinsic brightness of its stars, but the general rule is that more distant galaxies are fainter because the density of stars falls off as you go away from their centers, and so the number of stars within a given angular patch doesn't go up fast enough as you increase the distance to compensate for the decrease in individual stars' brightnesses due to their being at larger distances from us.