THIS! I had a rude awakening to this fact. Its a game, like politics, they just want to WIN, both sides. The person I know, ended up having to plea, even though they were completely innocent.
So yes, it does happen. Scary really.
Defense counsel probably knows if the accused are guilty, and in most cases, they are. Prosecutors don't know, but they'll settle for winning, secure in the knowledge that in most cases, the accused are in fact guilty.