Magnesium plays a critical role in numerous biochemical reactions and is necessary for proper muscle and nerve function. Hypomagnesemia can result from chronic alcohol use, certain antibiotics, and chemotherapeutic agents, which affect magnesium absorption or increase its excretion. Hypermagnesemia is less common but can occur in cases of excessive magnesium ingestion, such as with overuse of magnesium-containing laxatives or antacids.