Gravity is a curvature of spacetime. The amount of that curvature affects how space is different from one time to another: in other words how fast space expands.
In particular, the equations describing the expansion of space are, at base, the equations of gravity applied to the universe as a whole. The rate of change of the expansion is determined by how much matter and energy there is (this includes dark matter and dark energy). Each component of the energy balance: regular matter, dark matter, radiation (light), dark energy has its own contribution to gravity because of how the density of each is affected by that expansion. That, in turn, determines the rate of expansion.
In particular, the equations describing the expansion of space are, at base, the equations of gravity applied to the universe as a whole. The rate of change of the expansion is determined by how much matter and energy there is (this includes dark matter and dark energy). Each component of the energy balance: regular matter, dark matter, radiation (light), dark energy has its own contribution to gravity because of how the density of each is affected by that expansion. That, in turn, determines the rate of expansion.