Yep. Every defense attorney is obligated by professional conduct to provide a defense, even one that's totally absurd. If they don't defend their client, any guilty verdict could be thrown out for ineffective counsel. Nobody wants a retrial (except, perhaps, the defendant). In this way, a competent defense attorney actually aids the prosecution in reaching a verdict that will stand up under appeal. This is why the defense attorney will throw everything against the wall and see what sticks, no matter how ridiculous.
From the outside it looks like a mockery of justice but there's good reason for it. Most of the time it works. A good prosecutor will do his job and prove a truly guilty defendant guilty and because the defendant was adequately represented, this verdict has a better chance to remain in place.
Good point. I forgot about the fact of a poor defense can lead in a dismissal or retrial.