Gravity is the force of attraction between masses.
The larger the masses, and the closer they are to each other, the greater the attraction.
The force of attraction between the Earth and an object at its surface is about 9.8 Newtons for a 1 Kilogram mass.
We call this the object's weight (on Earth).
The weight of an object on the surface of the Moon is about 1/6 of what it is on Earth.

The gravitational force between two objects A and B, whose centres of mass are a distance D apart, is given by the formula:
Force=G*MassA*MassB / D2
where G, the gravitational constant, is 6.67x10-11 Nm2Kg-2

If one of these masses is a planet or moon, and the other a much smaller object sitting on its surface, we can rewrite the formula:
Force=G*objectMass*planetMass/(planetRadius)2

Because the G and the planet mass and radius are constant, we can lump them together as a single value;
g=G*planetMass/(planetRadius)2
where g is measured in units of N/Kg, or alternatively in ms-2

The gravitational force on a mass at (or very near) the surface of a particular planet (ie its weight) is given by the formula;
F=mg

The alternative interpretation of g in units of acceleration (ms-2) is borne out in its most common name -  "the acceleration due to gravity" - reflecting the fact that (in the absence of other forces) an object dropped near a planet's surface accelerates downwards at g ms-2