One thing you might learn in math is to avoid making overgeneralized statements that you can’t support.
A valid substitution in your statement for “programming” is writing a compiler. And for “undergraduate mathematics taught in math departments”, basic differential calculus.
Yet we regularly teach smart high school students and first-year undergraduates calculus, and almost never try to teach them to write a compiler, contradicting your proposition.
But what do I know? I’m just a dumb programmer. I can’t read your mind, so maybe you had something a little more specific you wanted to say.
High school students are taught plug-and-chug calculus where one uses rules and formulae without any real understanding of the underlying subtleties that make calculus work.
Programming is child's play compared to undergraduate mathematics taught in math departments. It's important that you take a module from the math department, not from a physical science or engineering department if you want to experience what it is like.