Both / they're related. More mass gravitates more.
Suppose you had an infinite universe that was filled with a cool gas of low uniform density. Then the gravitational field at any particular point would be 0, by Gauss' law.
But, if you wait a brief moment the gas will not stay uniform, because each atom of the gas will have some velocity. You'll observe fluctuations: places with small over-density and small under-density (compared to the average). The places with over-density will gravitate more than the average and places with under-density will gravitate less, and gravity will cause the gas to clump.
Wait a few billion years and some places will have amalgamated whole galaxies' worth of matter around them and other places will be empty.
Suppose you had an infinite universe that was filled with a cool gas of low uniform density. Then the gravitational field at any particular point would be 0, by Gauss' law.
But, if you wait a brief moment the gas will not stay uniform, because each atom of the gas will have some velocity. You'll observe fluctuations: places with small over-density and small under-density (compared to the average). The places with over-density will gravitate more than the average and places with under-density will gravitate less, and gravity will cause the gas to clump.
Wait a few billion years and some places will have amalgamated whole galaxies' worth of matter around them and other places will be empty.