their defense when you know they are guilty and have admitted it to you for one.
You don't ask your clients if they're guilty. They're presumed innocent. You ask questions and prepare a defense in light of that. You look at the other side's case through discovery (and vice versa) and determine the best course. Most clients capable of criminal activity will lie to their attorneys in any event. The ones who will tell you they did it will also usually run to the plea. Because criminals don't tend to be smart, will often leave behind sufficient evidence to put themselves in serious jeopardy.
The ones that don't are either very smart/good at what they do or lucky. And then there are the actually innocent.
When you try to supress actual proof of the crime by some legal technicality or loophole, things like that...
Legal technicality and loophole are mostly things people pick up watching the distorted hyperbole of television or movie courtroom drama and/or comedy. There's the presumption and there are the rules of evidence. There are very clear and good reasons for those rules and both sides are to follow them...Chain of custody relating to evidence is one of those that might be considered a technicality, but for the defense attorney it's mostly about making sure the state, with its disproportionate power and resource, stays within the written letter of the law. And the state examines and objects and makes sure the defense does also.
That's an ethical and moral obligation. Both parties have a Constitutional obligation. If we do our jobs then justice prevails, provided the trier of fact does his/her/theirs.
Even the plea deal process contains selling of morals.
No, it doesn't, not inherently or for the most part. I'm sure there's an exception to any rule, so I won't say it doesn't happen. But juries get it wrong too, both ways. We've put innocent men to death and let guilty men go free. Those are the tragic exceptions to the rule and no process in this world is perfect.