One method they use is called parallax, which yields the distances to the very nearest stars. But you don't need the details to get an understanding of how it works, so I'm going to shamelessly gloss over most of the spectroscopy involved in order to make the concept clear. The further a star is from you, the dimmer it appears. This is true for any source of light. So at first brush, it looks like the dimmer a star appears to us, the further away it must be.
Bright stars are close, and faint stars are farther away.
This simple idea would work perfectly if all stars had the same intrinsic brightness. A 100 Watt light bulb is brighter than a 60 Watt light bulb. They both appear brighter if they are closer to you, and look dimmer if they are farther away, but the 100 Watt bulb is always emitting more light than the 60 Watt bulb. Or they might appear to be the same brightness. Stars have wattages too, of course.