I believe the distance is calculated by observing a certain type of supernova in the target galaxy and measuring the 'red shift' of the light that we observe. The certain type of supernova shine at what was believed to be a specific brightness anywhere (that could be a wrong assumption according to new data from other studies), and we measure how much that light that reached us has 'shifted' towards the red end of the light spectrum which gives us the distance estimate.
I may be getting the explanation wrong, but this is how I understand it.