The scatter in the galaxy size versus stellar mass (Mstar) relation gets largely reduced when, rather than the half-mass radius Re, the size at a fixed surface density is used. Here we address why this happens. We show how a reduction is to be expected because any two galaxies with the same Mstar have at least one radius with identical surface density, where the galaxies have identical size. However, the reason why the scatter is reduced to the observed level is not trivial, and we pin it down to the galaxy surface density profiles approximately following Sersic profiles with their Re and Sersic index (n) anti-correlated (i.e., given Mstar, n increases when Re decreases). Our analytical results describe very well the behavior of the observed galaxies as portrayed in the NASA Sloan Atlas (NSA), which contains more than half a million local objects with 7 < log(Mstar/Msun) < 11.5. The comparison with NSA galaxies also allows us to find the optimal values for the mass surface density (2.4m0.9p1.3 Msun/pc2) and surface brightness (r-band 24.7pm0.5 mag/arcsec2) that minimize the scatter, although the actual values depend somehow on the subset of NSA galaxies used for optimization. The physical reason for the existence of optimal values is unknown but, as Trujillo+20 point out, they are close to the gas surface density threshold to form stars and thus may trace the physical end of a galaxy. Our NSA-based size--mass relation agrees with theirs on the slope as well as on the magnitude of the scatter. As a by-product of the narrowness of the size--mass relation (only 0.06 dex), we propose to use the size of a galaxy to measure its stellar mass. In terms of observing time, it is not more demanding than the usual photometric techniques and may present practical advantages in particular cases.