The difference is gravity. Weight is dependent on gravity while mass isn’t. So if you had a 5 kg object and you brought it to space, the weight would be 0 but the mass would be the same.
Grams are a measure of mass, not weight. If you’re being pedantic, newtons would be the measure of weight in the metric system, but since the vast majority of us only have to deal with Earth’s gravity, we use mass and weight interchangeably.
Latest Answers