Not only that, but the Grand Am was cheaper and better-equipped than most of the Contour lineup.
The Contour is on a modern chassis and has great driving dynamics, but the additional complexity of the car itself made it more expensive.
The Grand Am is on an old, cheap chassis that probably paid for itself years ago, so it could be loaded up with a nice CD player, automatic headlights, remote keyless, etc, etc at the same price as a more basic Contour.
It doesn't take a rocket scientist to figure out that typical compact car buyers will take the crappy car that has a bunch of goodies over the superior but more austere model.