I've heard about how time dilation causes gravity (not the other way around) but what
about the
object is not moving, then why can time dilation affect it?
No, time dilation does not cause gravity.
However, the gravitational field, which doubles as the spacetime metric, determines how clocks
measure time and how meter sticks measure distance.
And it turns out that when it comes to weak gravitational fields and negligible velocities (i.e., our
“normal” experience here on the surface of the Earth) the only term in the mathematical expression
characterizing the gravitational field that has any significance is the time dilation term.
So to a very good approximation, Newtonian gravity and time dilation are the same thing. One does not
cause the other. They are manifestations, or representations, of the same physical field, the
gravitational field.
In practice, it means that the stronger the gravitational field gets, the slower clocks tick in it. This is
measurable and confirmed by observation. Very high precision atomic clocks can, in fact, measure a
difference of just a few centimeters (!) in altitude: Move the clock up a little, and it already ticks ever so
slightly faster because it is a few centimeters farther away from the center of the Earth.