Sometimes things we think of as different are actually just different forms of the same thing. Electric fields and magnetic fields are forms of each other. That is why we now call it the electromagnetic force.
Likewise, energy and mass are also just different forms of the same thing. We can even convert it too.
E = mc^2 ...
And from what I understand, space and time are connected together as well. So it gets called spacetime. If you want to think about it that way, gravity works by warping space, like a heavy marble sitting on a fluffy blanket. The fluffy blanket is spacetime. The heavy marble is a black hole or other super massive object. So now light is still going "straight" along space (the fluffy blanket) but it is bent because the blanket is bent. (Caveat: this is where i am conceptualizing light as a wave, not photon packets. It is actually both.) And if gravity bends space, of course it bends time too, because space-time is connected somehow as the same substance.