Thinking about this in the abstract makes it easy to think this way! I'm not an attorney. I am a retired police officer who does contract work for defense attorneys.
Everyone is entitled to defense counsel. It is a cornerstone of our judicial system. Perhaps they are guilty. Then your job is to get them the best terms as far as sentencing is concerned. Perhaps probation. Or, maybe the state's evidence is weak. Then it is your job to create reasonable doubt in the minds of the jurors.
Suppose a 19 yr old holds up a store. No one gets hurt. He is married and has a baby. Should he be locked away for 20 years? This is more likely to result in his wife and baby being on welfare, baby growing up without a Dad, etc. He also has siblings, parents, etc. It's a very human issue.
A person is innocent until proven guilty. If the state cannot prove its case, your client should go free. Sadly, prosecutors believe they should try to get convictions, and sometimes aren't too forthcoming with exculpatory evidence. I worked on a case where the police said our client dropped narcotics from the wristband of his jacket. Except, he was wearing a short-sleeved shirt. Someone needs to point these things out.
Now, when it comes down to truly heinous crimes, I ask myself the same question. I could not work on a case of a mass shooting suspect, for example.
When I first started working for defense attorneys, after having been a police officer, I thought I would have trouble with this. But when you start seeing all the "mistakes" made by police and prosecutors, as well as the excessive use of force situations (I do some Civil Rights cases as well), it all starts to come together. If a guilty person goes free and commits subsequent offenses, it is NOT the fault of the defense attorney - it means the prosecution failed to prove its case.
Hope this helps.