The idea behind being a defense lawyer is to provide the best possible defense even if you know that the person who you are defending is guilty of a crime. It is the judge or jury's job to determine guilt or innocence, in the eyes of the law.
Honestly, if you have reservations about this then I would suggest not becoming a defense lawyer, because it is one of the job requirements.
There are still lots of other positions in the courtroom available if you are interested in becoming a lawyer.
Sometimes lawyers who defend people who actually commited the crime, try to get their client to cut a deal with the police officers. Its an efficient way to protect moral values without betraying your case, client or the law. Lawyers like that, are hard to come by that care about the law and not just the money. I hope I helped answer your question.