I have sensitivity to mineral supplements and get similar side effects to the ones you described.
This is the only magnesium malate supplement I've found that I can tolerate is: https://www.amazon.com/dp/B083QPN3DR