You teach someone how to do X, lets assume this goes something like: Step 1, Step 2, Step 3, Step 4, done. You then teach someone how to do Y, this goes like: Step 5, Step 6, done. On the exam you ask someone to do Z. This follows from a nontrivial combination of Step 1, Step 3, Step 6, done. If anyone gets it right, don't flatter yourself. You didn't teach them how to do Z.
Either they have a sort of a priori intuition of the material (this is how I get by most of the time), they got lucky, or they had someone else teach them. Mathematicians (and other academics) feel the need to make their subjects so obtuse they seem insurmountable. Math is not hard - some guy saw an interesting behavior of a function and wanted to see what happens when he tries to differentiate it. Programming is not hard - some girl thought she could make her life easier by writing a program that writes other programs. This pretty much exemplifies all of human understanding. It's not much more than that.
Of course I'm not suggesting that complex analysis or the Dragon Book are trivial, all I'm saying is that they are not hard. But academics themselves often discourage people from pursuing science and math (numerous examples in this thread alone). We can blame the government, elementary schools, and parents all we want, but it's blatantly obvious that universities are broken. The fact that students are tested on material not covered in class (or nontrivial combinations of material covered in class) is inane.