Because magnesium capsules and multivitamins are formulated to be safe for your stomach lining. Just putting a bunch of salt into an empty gel capsule and swallowing it is not safe for your stomach lining. It would be like reaching down in there and just pouring a spoonful of salt directly onto your stomach lining.
(Incidentally, some multivitamins can irritate an empty stomach too, though they won’t actually burn holes in your stomach lining like a capsule of salt will. I tried taking a multivitamin with iron while fasting, and immediately puked it back up.)