i get that mgso4 contains oxygen and the other one doesn't.
But how???? Is magnesium reacted with sulfur and oxygen to get magnesium sulfate or something??
Does it matter how they are produced? There are so many “slightly different” molecules out there that your life would waste away if you tried to work out why all of them can exist and how they came to be.
It’s simply because of whichever atoms are preferred and attracted in that situation to produce the substance.