Magnesium, when it comes into contact with water, attracts a large amount of water molecules which arrange around the Magnesium ion, this is referred to as a hydration shell. The hydration shell physically makes Magnesium bigger which makes it harder for it to pass through tight junctions in the small intestines. Compared to Calcium, Magnesium has a much larger hydration shell, which causes two issues, the first being that Magnesium has a much harder time being absorbed due to its large hydration shell and the second issue is that when Magnesium and Calcium are coingested, then they are going to compete for absorption, which is problematic because Calcium will generally have the upper hand due to its much smaller hydration shell, which will limit the amount of Magnesium that can be absorbed.
The second major issue that makes things even more complicated is that Magnesium increases pH levels at tight junctions when ingested in supplemental dosages. This is problematic because there are proteins in the tight junctions called Claudins that strip Magnesium of its hydration shell allowing it to pass through the tight junction. However, as pH increases, Claudins become less and less active. As a result, Magnesium limits its own absorption by gradually increasing intestinal pH.