Occasional muscle spasms in an underweight and undernourished person are a classic sign of magnesium deficiency (hypomagnesemia). Magnesium plays a key role in neuromuscular transmission and muscle contraction - low levels lead to increased neuromuscular excitability, causing spasms, cramps, and tetany.
In an underweight/undernourished person, the triad of muscle spasms + malnutrition most specifically points to magnesium deficiency, as magnesium is commonly depleted in states of malnutrition, malabsorption, and poor dietary intake. Calcium deficiency is a close second, especially if there is also vitamin D deficiency.
In clinical MCQ settings, if the question emphasizes "occasional spasms" with general undernutrition, the expected answer is typically magnesium. If it emphasizes tetany with a more specific clinical picture, calcium may be intended.