This is a very good question, because it provides an opportunity to talk in more detail about what gravity is, how the theory of relativity works, and how our space-time works.
Black holes really refract light passing near them. This effect is called gravitational lensing, it was discovered a long time ago and is inherent not only in black holes, but also in any other massive bodies. On black holes, it is simply best seen.Most people think this way: photons have no mass, which means, according to the law of universal gravitation, gravity should not act on them. Right?
However, this is correct only from the point of view of Newtonian gravity, which, although suitable for ordinary calculations, absolutely does not give an understanding of what gravity is. Newton's law of gravity is empirical, it gives a simple formula by which you can calculate the force of attraction between massive objects, but it does not explain where this force comes from.When it comes to the nature of gravity and its special properties, the general theory of relativity (GR) comes to our aid. Einstein described gravity as a curvature of space-time, and it is as a result of it that bodies are attracted to each other.
Any body with mass bends underneath the fabric of space-time and forms the so-called gravitational well.This is usually illustrated using an analogy as in the photo above: a massive metal ball in the center significantly bends the two-dimensional tissue of space under it, and the curvature of the tissue under the ball causes less curvature around it. Thanks to the grid marked in advance on the fabric, you can clearly see how straight paths are curved near the massive body.The more massive the object is, the deeper its gravity well will be, and the denser the object, the steeper the walls of the well will be. A black hole's gravity well will generally be infinitely deep.
In space, photons always move in a straight line, however, when they fly through a gravitational well, then, from the point of view of an external observer, their trajectory is curved in the same way as straight lines on the fabric next to the metal ball were curved.Thus, for an external observer, the trajectory of a photon near a black hole looks curved, but from the point of view of the photon itself, it always moves in a straight line, just space itself is curved on its way. When a photon falls under the event horizon of a black hole, space becomes so curved that the trajectory of the photon through it becomes infinitely long. Trying a photon to fly out from under the event horizon becomes like trying to run to the end of an extremely fast treadmill.