Newton’s Second Law states that
F = m a
(Vectors in bold)
Weight = gravitational force (units of Newtons in SI units)
F = m g
g being the acceleration due to gravity.
On Earth, g ~ -9.8 m/s^2
Changes in weight
But that acceleration will change depending on position on the Earth and altitude and will also change on the moon, in space, and in other places.
You can find the acceleration due to gravity by dividing the gravitational force by the mass.
There is an acceleration due to gravity whenever there are two masses, they can be a person sized mass and a planet sized mass, two smaller masses, or any combination of two masses.
Therefore the weight is less or more depending on where it is.
There is less gravity on the moon, so the weight is less there (for the same mass) compared to on Earth.
Let’s say on a bigger planet ‘X’, the mass of the planet is more than Earth. Therefore the acceleration due to gravity is greater and weight would be greater (for the same mass) compared to Earth.
If there are no other masses nearby, in space for instance, things are weightless.
You can use the Law of Gravitation for various situations.
Here’s a diagram