Chelated forms of magnesium, such as magnesium glycinate, would have less of a tendency to cause discomfort. If, however, you typically take in high amounts at one time, you’d still possibly experience some discomfort as the magnesium pulls water into the intestine regardless of form.
Trying smaller amounts of magnesium supplements at one time might be helpful. Magnesium orotate is also easily absorbed, so you might be able to get by with smaller amounts to avoid discomfort while also achieving adequate supplementation. Learn more about the health benefits of magnesium.
As for calcium supplements, calcium citrate is well absorbed and less likely to cause discomfort than calcium carbonate.