Astronomers estimate the number of stars in galaxies using methods that involve calculating the average number density and volume, rather than direct observation. The mass of a galaxy is often inferred from its rotation speed, which is measured through Doppler effects, and this mass is related to the number of stars, albeit complicated by dark matter. For instance, if the Milky Way's mass is estimated at 1 trillion solar masses, with an average star mass of 0.5 solar masses, it could suggest around 2 trillion stars, though this is a simplified example. Dark matter plays a significant role in these calculations, with estimates indicating that only a fraction of a galaxy's total mass is made up of stars. Overall, the complexities of estimating star counts involve both observational data and theoretical models that account for various cosmic components.