How energy curves spacetime?
Theoretical viewpoint:
Einstein field equations can be written in the form: $$\color{blue}{G_{\mu\nu}}=\color{red}{\frac{8\pi G}{c^{4}}} \color{darkgreen}{T_{\mu\nu}}$$ We can write in simple terms: $$\rm \color{blue}{Space-time \,\,geometry}=\color{red}{const.}\,\,\color{darkgreen}{Material \,\,objects}.$$ And the $T_{\mu\nu}$ is a mathematical object (a tensor to be precise) which describes material bodies. In that mathematical object, there are some parameters such as the density, the momentum, mass-energy... etc. So it is those parameters that determine 'how much space-time curvature' is around a body. And one of the parameters is of course energy. Therefore, energy do bend space-time.
Experiments that confirm this point:
First, do photons have mass? The answer is an emphatic 'no'. The momentum of a photon is $p=\frac{hf}c$, and from special relativity: $$\begin{align}E=\sqrt{(mc^2)^2+(pc)^2}&\iff E^2=(mc^2)^2+(pc)^2\\&\iff E^2-(pc)^2=(mc^2)^2\\ \end{align}.$$ The energy of a photon is: $E=hf$ which is an experimental fact. It can also be expressed as $E=pc$ since $E=hf=\frac{hf}{c}\cdot c=pc.$ Therefore, $E^2=(pc)^2$ and so $E^2-(pc)^2=0$. Putting this in our previous derivation we get: $E^2-(pc)^2=(mc^2)^2=0$. Since $c^2$ is a constant, then $m=0$. Therefore, photons have no rest mass.
Claim: Photons are not subject to gravitational attraction since they have no rest mass.
Experimental disproof: Gravitational lensing:
You could see light being bent due to the presence of a strong gravitational field.
Conclusion: Even if light has no rest mass, it has energy and momentum. And it is being attracted due to gravity, so the natural conclusion is that energy do curve space-time.
Matter curves the spacetime because (experimentally verified and mathematically natural) Einstein's equations that govern the spacetime curvature say that the local-curvature-encoding Einstein tensor $G_{\mu\nu}$ is proportional to the stress-energy $T_{\mu\nu}$. The latter contains numbers, especially the density of mass-energy and momentum and their flux (which also depends on the local pressure).
Because matter carries mass-energy, it makes spacetime warp. Any other form of mass-energy will do the same thing. I say mass-energy because in the context of relativity, mass and energy are really the same thing due to the well-known formula of special relativity, $E=mc^2$, which says that one unit (e.g. kilogram) of (relativistic) mass is equivalent to $c^2$ units (joules) of energy.
Mass or energy may be stored in various forms but they ultimately have the very same impact on the spacetime curvature (and other things). Some of the forms of mass-energy look more like mass, other looks like what we used to call energy but there's only one type of quantity that curves the spacetime and one quantity that is conserved.
According to Newtonian gravity if you made 100 million cannon balls (10kg each) and shipped them to deep space assembled them with some explosives and exploded it with enough force so none get hurt but they all went out spherically to a maximum of 2 miles (if you don't know what a mile is, just read it as a km and none of the physics will be different but the abbreviation is mi and I do use that later) from the center that only the mass of the cannon balls and the number of them matters, so it would be like a (very small) planet of mass 1000 million kg. Specifically, Newtonian gravity says you could instead send more explosives to shoot them so that they all travel spherically outwards for 10 miles and someone orbiting them would feel the same gravitational attraction as if you made a 2mi explosion of the balls, so it would be like a (very small) planet of mass 1000 million kg either way.
General Relativity disagrees. Which is good. Because that additional explosives to make it 10mi instead of 2mi had some mass and the gravitational attraction far away shouldn't change the instant you set them off. Not the exact same instant at least, since nothing should go faster than light by just setting off an explosive.
On the one hand your question looks like it has an easy answer, it is actually the energy associaited with the mass that makes curvature. The mass itself did nothing, only the energy associated with the mass did something. but that answer, while accurate, sidesteps the whole question about how curvature is caused.
The first thing to know about curvature is that it is natural. Einstein's equation $R_{ab}-\frac{1}{2}g_{ab}R=kT^\frac{8\pi G}{c^4}T_{ab}$ has a version for vacuum that is $R_{ab}-\frac{1}{2}g_{ab}R=0$ and that equation does not say that curvature is zero. It says that certain combinations of rates of change of the metric have to balance against the existing current metric. So certain metrics have to change certain ways. The equation allows, for instance, gravitational waves to propagate through empty space with the rate of change of curvature in a region changing according to the way curvature varies nearby.
So curvature is natural, even in empty space, and curvature can cause itself, either causing curvature nearby or causing future curvature right there. And certain kinds of curvature line up just fine in spacetime, and other do not. The kinds that do line up solve $R_{ab}-\frac{1}{2}g_{ab}R=0.$ The kinds that do not line up naturally, don't solve $R_{ab}-\frac{1}{2}g_{ab}R=0.$
The second thing to know about curvature is to note that $R_{ab}-\frac{1}{2}g_{ab}R$ always has the property that its (covariant) divergence vanishes. That means it is possible to have matter that equals $R_{ab}-\frac{1}{2}g_{ab}R$ because matter has its (covariant) divergence always vanishes. Some people go a bit extreme with this, they make spacetimes with warp bubbles and long lived wormholes and say, well you just need to put some really really really weird matter right in the right places.
But it does mean that matter can make things curve differently than it naturally would in a vacuum. Let's use that to see how matter can make spacetime curve.
Take two different natural curvatures. For the first, you can take the way the vacuum spacetime outside a planet in deep space is curved (the simplest one is called a Schwarzschild spacetime), since it is the region outside a planet where it is all vacuum, this is the kind of curvature that exists fine on its own, and even is curved just right so as to make the curvature in the future be just like the curvature now. For the second natural curvature, you can take a flat spacetime (called Minkowski spacetime). If you take a ball of radius 10 miles and take that region of flat Minkowski that can be your first region. Then you can take the Schwarzschild solution for a parameter of $M= 1000 million kg$ and cut out a spherical surface of surface area $4\pi (10mi)^2$ and glue the ball of Minkowski spacetime to the exterior of the Schwarzschild spacetime, so it is Schwarzschild on the outside and Minkowski on the inside
Anytime the surfaces line up, it is a possible spacetime. But the matter might have to be be really really weird. Do we need really really weird matter? No. Having the 100 million cannon balls of 10kg each that came to rest at 10mi from the center is exactly the right distribution of matter to sew those two solutions together.
And now as the canon balls come down we can see curvature get created. There is no curvature on the inside of the spherical shell of cannon balls. But as the canon balls fall down, the region right outside the outer shell doesn't have matter there anymore so it has to evolve in the natural (vacuum) way, but the curvature out there is the Schwarzschild curvature, which is one of the kinds of curvature that naturally evolves to itself, so the curvature right outside the shell of cannon balls will make more of itself inside if there is nothing to stop it.
And when I say more of itself, I strangely mean exactly that. A totally interesting (or mind blowing) feature is that when the cannon balls get to only being 9mi from the center the distance outside the shell of falling cannon balls is more than 1 mi away from where it started. When the cannon balls fall, the Schwarzschild solution outside creates more distance between itself and the region outside than it eats up from the inside down. It's like making a giant funnel that is deeper, to make the funnel go from a circle of circumference $2\pi(10cm)$ to a circle of circumference $2\pi(9cm)$ requires more than 1cm of distance between the two circles because the funnel surface is curved.
In out example it is like putting a flat disk of radius 10cm into your giant funnel and then taking it out and replacing it with a flat disk of radius 9cm, there will be more funnel visible because the smaller one covers up less of it. Normal geometry holds on the disk and curved geometry holds on the funnel. We are doing the same thing but in a higher dimension.
OK. So now we see how curvature gets created. Every galaxy was made in the past by matter infalling towards the center, as each shell of matter crosses over a spherical thin shelled region it ties together a region less curvature on the inside to a region of more curvature on the outside. Why? Because that is what ordinary everyday regular matter does. It's not really really weird matter, so it connects higher curvature on the outside to lower curvature (or none) on the inside. Thus leaving the outer galaxy curved so that the sun could one day orbit the galactic center. And similarly as the sun formed layer by layer, it connected a region of more curvature on the outside to a region of less curvature on the inside, leaving the solar system curved outside the sun so that we could one day orbit the sun. And similarly as the earth formed it left the region i\outside itself more curved, so that the moon could orbit the earth.
Now I said that GR gives a different curvature for the 2mi explosion and the 10mi explosion. Let's see what happens when the cannon balls get to 2mi away from the center. There are still 100 million cannon balls. And they still have a mass of 10kg each. But they have fallen 8 (or more?) mil and have been speeding up the whole way. They have more energy. And it is actually the energy, momentum, pressure, and stress of matter that allows different curvature regions to be sewn together. If you had the same number of cannon balls at 2mi radius from the center but all of them were at rest, they wouldn't have enough energy to connect up to such a highly curved spacetime. What that means is that when you brought the cannon balls and the smaller amount of explosives they didn't curve the spacetime around themselves as much when they were brought in the first time.
This makes sense, if you brought less explosives in when you made your cannon ball explosion the spacetime outside was curved less. If you brought in more explosives, then you curved space more. So when the explosives are used up (your explosives could have been matter and antimatter that exploded into pure energy, both regualr everyday matter and the antiparticles versus of regular everyday matter are have positive energy and positive mass, those really really really weird matter that you need for weird spacetimes are really really really weird). So when the explosives are used up the cannon balls take off with lots of energy but that region of spacetime outside is still curved the same way it was when you sent the explosives down to the center. This higher energy matter (more energy because moving faster) has to be enough to convert that higher curvature on the outside into (less) flat space that becomes the inside. We know the curvature on the inside has to be zero for symmetry reasons (everything is spherically symmetric and there is nothing inside the shell of matter and we assume the cannon balls are not really really really weird so they aren't lined with negative energy on one side and extra compensating positive energy on the other).
You can think of it as a certain amount of energy density leaves behind empty space of less distance than the curved surface distance it eats up as it expands. But that rate is determined by the energy and momentum and pressure and stress. And not by mass. Gravity and curvature are not created by mass, they are made by energy (and momentum and pressure and stress). Energy and momentum and pressure and stress together make $T_{ab}$ and together they evolve in such as way as to have zero (covariant) divergence so only those can patch together a nonzero term on the left hand side of $R_{ab}-\frac{1}{2}g_{ab}R=kT^\frac{8\pi G}{c^4}T_{ab}.$
Since it is energy, not mass, that evolves with zero covariant divergence it is energy, not mass, that can follow that seem of expanding and contracting space as the place where the vacuum solutions of natural curvature evolve. The sum of the rest masses of the parts does not change over time the way you need to patch up the two different natural curvatures to each other based on how the two natural (vacuum) curvatures evolve on their own.
So it is energy, not mass, that is the source of gravity, and by source, we mean something that can piece together different natural regions of curvature, energy changes as the surfaces move in such a way to allow it to continue patching them together (possibly making more space on one side than it eats up on the other, but that's really about keeping the differently flowing rates of time to line up, if time flows slower on the regions farther away from the outside of a surface, you need to make more space on the outside as you flow the surface in.
OK. I've answered your question, but there is one detail I want to be honest about. For brevity I sometimes talked about "more curvature on the outside" and "less curvature on the inside" and what I meant was like if you had two layers of thin shells then inside both it might be flat and in between the two shells it might look like a curvature similar to a star of "lower mass" and outside both of them it might look like a curvature outside a star of "higher mass". That's what I meant by higher curvature, and lower curvature. Around a star of fixed mass, the true real objective curvature gets smaller the farther out you are. So when the galaxy was forming, the curvature was small out here and as the contracting galaxy had lots of matter move in closer, it extended that curvature out here that was slight into a curvature closer in that was curved "the same" way, i.e. that natural vacuum kind of way. But that "same" way naturally has more actual curvature closer in, so there is more curvature closer in, and I didn't want to be misleading about that. But I was trying to make it clear that you have one type of natural curvature and another type of natural curvature, and they can be types that have higher or lower curvature (at the same distance from very very far away bodies). So my talk about more and less curvature was accurate when the matter was right there and the two regions where touching right there. It's just that later when the matter has moved on that natural region of curvature itself allows curvature to change from point to point. In our example, that means as the cannon balls fall in, the new additional region of more curved space created outside isn't just more space and isn't' just more curved because it is more of the type that was outside (which was more curved) it is even more curved than the stuff that used to be outside because the type of curvature that is outside is the kind that gets more curved the closer in you get (and that is also because it was made from normal not weird matter).
I hope that wasn't too confusing. But I wanted to have a real answer out here about what makes curvature and what i\t means to be a source of curvature. It means that you allow different natural curvatures to line up so you can make one transition in to the other, thus make more or less of one of them.
Potentially alowing one to build up more of a region to give it a chance to get stronger curvature in a direction if it is the kind of curvature that gets stronger in a direction. Leaving stronger curvature on the outside means the newly created region has the stronger curvature, so contracting matter (that isn't weird matter) creates more space and more curvature as it contracts.