It isn't really a case of being "equal to", its more a case of having a certain volume. BUT it all depends on density.
If you consider water, which has a density more or less equal to 1
But if you are considering something else, with a different density, then its a different calculation. If you take, for example, something like engine oil, this will have a density of around 0.9
So for water, 1 g is not "equal to" 1 ml, but it does have this volume.