I understand how we can measure the luminosity of a close star through absolute and apparent magnitude, because we can easily find the distance through trigonometric parallax. What I have understood about standard candles is that if a distant star has a similar luminosity to a close star, it's identified as a standard candle. Through that we would know the absolute magnitude of the distant star as it falls in the same category of the close star and thus we can find its distance from Earth. However I don't understand how do we find the luminosity of a distant star without the absolute magnitude?
The cepheid variables https://en.wikipedia.org/wiki/Cepheid_variable were the first standard candles to be identified as such. Their period-luminosity relation (second paragraph in that wikipedia link) was discovered by direct parallax measurements of distances to nearby ones, and then noticing the relationship between their absolute magnitudes and periods. And a little later, the distance to Andromeda was first determined by identifying the very brightest cepheids in that nearby galaxy. And Hubble first determined the eponymous constant using cepheid-determined-distances to Andromeda and various other nearby galaxies.
Much more distant galaxies don't contain cepheids bright enough to be seen from Earth. Instead, type Ia supernovae https://en.wikipedia.org/wiki/Type_Ia_supernova have "consistent peak luminosity" (quoting that link), way brighter than cepheids, and thus visible from Earth at much greater distances, allowing those distances to be determined. They're probably responsible for the majority of galactic distance determinations. But they're pretty much catch-as-catch-can. A typical milky-way-like galaxy has roughly one such explosion every hundred years. And you have to happen to be looking when it occurs. Nevertheless, lots have been serendipitously seen.
These and several other standard candles are discussed at https://en.wikipedia.org/wiki/Cosmic_distance_ladder (and google "standard candle" for additional discussions).
Imagine you are standing in a tall building looking out at the lights of a city in the night. You notice lights from windows, from street lights, and from car headlights. All these have a brightness at your eyes that depends on their distance from you.
Now you make a reasonable conjecture. You guess that the lights which have similar properties will have similar absolute brightness. For example, lights moving along in pairs (car headlights) probably have similar brightness to one another. Lights with a rectangular shape around them (windows) are probably more like one another then they are like lights moving along in pairs. Lights standing still in rows (street lights) are like one another.
It is similar in astronomy. Stars with a certain pattern to them, such as the way their brightness varies as a function of time, are found to have the same brightness at our detectors when they are in groups at the same distance from us. So we guess that if some other star, not in the group, has that same variation as a function of time, then it is probably the same type of star. So if it looks dimmer to us, it is reasonable to suppose it is because is further away.
That is the basic idea. In practice it is worked out much more fully and carefully than I have written here. Very many parallax measurements are made in order to gather information about close stars, and as many different types of star are tried as possible, in order to test the ideas. Only then do we get confident enough to assert that we can determine the absolute magnitude of some types of star without needing to know their distance, because we deduce it from other properties such as variation over time.
Also, of course, if you see a galaxy, then it is a pretty good guess that its overall absolute brightness is a lot more than any single star!