The math exam tests your mastery on the one hand, and your proficiency on the other.
Mathematics learning process: understanding, mastering and application. The test is the application and your reaction speed.
Your learning process only stays at the master stage, and of course you have stage fright in the exam.
The solution is to do more problems, sum up ideas, standardize the steps of doing problems, improve proficiency and accelerate the speed of doing problems.
Not everyone's brain is smart enough to learn math, but there are many such people.
Talent is only an additional factor, and learning tyrants all roll out of the pile of problems.