What you tell a lawyer is privileged information, but often lawyers don't know for certain whether clients are guilty or innocent of the crimes for which they are charged. If you go on trial for a crime, it's up to your lawyer to give you the best defense possible. That means your lawyer doesn't have to know whether you are guilty or innocent to defend you.
Burden of proof, not innocence, determines a case
Defense lawyers don't base a case on proving a client's innocence. Instead, they argue the evidence the state presents. They find ways to poke holes in the prosecution's case.
Since the prosecution has the legal burden of proof, it's up to the state to prove beyond a reasonable doubt that you committed the crime for which you are on trial. Therefore, your criminal lawyer doesn't have to prove your innocence.
It's the job of the prosecution to prove you are guilty of committing the crime. The prosecution must be convincing when presenting its case. Otherwise, your lawyer can put doubt in the minds of the judge or jurors by showing that the prosecution doesn't have enough factual evidence to convict you.
Right to a defense
Even if you admit guilt but want to plead not guilty, a lawyer can still defend you. That's because you are innocent until the prosecution proves you are guilty. By law, you have the right to an adequate defense. Consequently, defense lawyers aren't as concerned about whether clients committed the crimes of which they are accused. Their concerns lie in whether the prosecution can prove a client committed the crime.
Also, there could be extenuating circumstances. For example, perhaps you committed the crime in self defense. Or, you could be lying to protect someone. If that's the case, your lawyer's job is to get you acquitted or convicted of a lesser offense.
What a defense lawyer may not do
Even when attorneys doubt the story a client tells them, they aren't legally obligated to check the facts. Therefore, your lawyer may accept your version of the facts. However, when presenting a defense, lawyers can't lie to a judge or jury about something they know their clients did. According to the American Bar Association's Model Rules for Professional Conduct, a lawyer may not knowingly "make a false statement of material fact or law to a third person."
Whatever the facts may be, your lawyer will encourage you to tell the truth. Your lawyer will not ask you to lie or commit perjury as part of your defense. Otherwise, if you give false testimony while under oath, you are committing another crime -- perjury -- and your lawyer is guilty of suborning perjury. Both are serious offenses.