Why does looking at distant galaxies act like a time machine?

Answer

Because light takes time to travel across the vast reaches of space

The speed of light is finite, meaning that light from distant objects takes years to traverse the distance to our detectors. When astronomers observe galaxies that are millions or billions of light-years away, they are seeing the light that left those objects millions or billions of years ago. By capturing these ancient photons, the telescope effectively provides a view of what the universe looked like in its infancy, allowing for a comparative study between the early cosmos and the modern universe.

Why does looking at distant galaxies act like a time machine?
Hubbletelescopeorbitlaunchobjective