How do astronomers measure how far a star (or galaxy) is away from the earth? How would they know that it has taken 13 million years for light to travel in space before it reaches us?
That's a big question, because there are loads of ways used to measure cosmic distances. Have a look at the Wikipedia article on the cosmic distance ladder for the gory details.
The idea of the ladder is to start with nearby objects like stars. We can measure their distances using a method called parallax. Back in the 90s a satellite called Hipparcos used parallax to measure the distance to thousands of stars. Once you know how far away a star is you can calculate how bright that star is. Now we know how bright that type of star is, we look for similar stars in other galaxies and measure the apparent brightness. Then from the apparent brightness we can use our knowledge of the real brightness to calculate the distance, and this gives us the distance of the galaxy. Now we know the distance of the galaxy we can calculate its brightness, and use that to estimate the distance to other similar galaxies, and so on.
I make this sound very easy, but it's actually hard to be sure if we've found a similar star or similar galaxy to our test one. In fact early measurements of distances were wildly off. To improve accuracy we look for as many different ways to estimate distance as possible. The Wikipedia article gives a comprehensive list so I won't type them all out again here.
Measuring distances to really distant objects remains hard, and astronomers are still coming up with new ways to estimate really large distances. If you Google for "distance measurements site:arxiv.org" you'll find dozens of papers exploring new ways to measure cosmic distances.
Also, conveniently, Type 1A supernovas always occur with the same energy and brightness. This makes them "standard candles"--you know the original brightness, so you can see how much dimmer it appears and infer the distance.