The term lens is an analogy. The actual behavior of light depends on the geometry of the space through which it passes. This is calculated using the field equations of General Relativity, which are exceptionally complex and difficult to solve, but the basic idea is reasonably simple.
Most of us probably had geometry at some point. Almost certainly, that geometry was Euclidean geometry. This is geometry resulting from certain self-evident assumptions called postulates. For centuries this was the only geometry. In the 19th century, though, mathematicians realized that other geometries are possible. They began to develop these non-Euclidean geometries, even though it was evident that Euclidean geometry describes the universe.
Well, as maybe you guessed, the true geometry of the universe is NOT Euclidean. We only think it is because we dont often deal with large distances. An anology is that the geometry of the earths surface appears Euclidean at small scale but not at large scale. Since we know the earth is non-Euclidean because its curved. By analogy, we say that the universe is also curved. The field equations simply relate this curvature to something easier to measure energy. Energy causes curvature. This includes matter as well (E=mc^2).
Theres another phenomenon caused by matter, gravity. Gravity is just the name we called curvature before we understood this. Gravity IS curvature. It is also why we get lensing. It is not the same phenomenon as a glass lens though, so results from such lenses dont apply
“This includes matter as well (E=mc^2).”
Chicken / egg ?
Which came first? Matter or Space ?