But suppose you're outside of an exam environment and have time to look up the relevant material. I've known a PhD candidate in a non-mathematics field who had to find a mathematical solution to a certain research problem. That person is smart but still needed a few months to learn the mathematical fundamentals to understand and solve the problem. In contrast, someone with a math background could have solved this far more quickly. But that person would have taken at least some months to get up to speed on the research literature for the non-mathematics part of the research problem, in order to properly understand its constraints and bigger-picture significance.
Lara Alcock's book "How to Study as a Mathematics Major" touches upon this topic more directly. She encourages readers not to be too intimidated if other students in a course seem really smart: much of the time, the reason is not due to an innate difference in smartness, but rather prior exposure by other students to concepts in the course. Students who seem to find the material effortless often have already studied many of the topics in another course or could even be retaking the course after a previous attempt.