Algebra is simple. It conforms to a small set of rules that are easily understood, often intuitive, and have few special cases. Problems are small, self-contained, and have clearly-defined parameters. They don't suddenly change on you halfway through the test, they don't have to account for unexpected input, and they don't have to interact with other problems.
Real-world computer programs exist in a large set of arbitrary, often unintuitive rules that are both absolute and malleable, and change between languages and platforms. They have complicated requirements that seek to solve real-world problems that are often ill-defined. They have to cope with unexpected input, hostile input. They are large, comprising hundreds, thousands, even millions of lines of code. They have a multitude of paths that a given piece of input might take, they display emergence.
Coding is not just a simple math problem. It requires clear, detailed reasoning about complex systems operating within arbitrary sets of rules and an unpredictable world.
Related questions might be "Why do people have trouble doing their taxes by hand?" and "Why do people have such a poor understanding of the legal system?". Also, chess.