Things you say to a non-lawyer may be used against you in a court of law. In particular, things you say to friends, to loved ones (depending on the relationship), to colleagues, to police, to investigators, to co-defendants, to conspirators, to enemies, etc. can and most probably will be used against you in a court of law.
Most people know about the Hearsay Rule. The Hearsay Rule means that stuff said out of court is not admissible in court to prove the truth of the matter. This means that in general, much of what is said out of court can’t be used against you.
But there’s a big, gaping loophole. And that’s an admission by you, the defendant. Statements by you outside of court can be used against you in court. Those are not considered “hearsay” and therefore are admissible.
However, things you say to a criminal lawyer are strictly confidential. If you ask your best friend for advice by saying, I did “X, Y, and Z. What do you think I should do?” you are in a world of trouble. That friend can be called as a witness and compelled to testify about what you said to him. What you said is not hearsay, and it’s not protected by confidentiality rules.
You can confide in an attorney. There are only a few exceptions to the confidentiality rule. A lawyer may not keep confidential any plans you have to commit future crimes. For instance, if you come to me and say, “I’m going to rob Bank of America tomorrow, how can I do it without getting caught” and I believe you will rob Bank of America, I am compelled to tell authorities. However, if you come to me and say, “Last Thursday I robbed Bank of America. No one knows it was me because I wore a mask. What can I do to avoid going to prison?” I must keep that confidential because it was a crime in the past, and I can advise you about how to protect yourself.
The attorney-client confidentiality rules mean that if you talk to a criminal lawyer about your case, the criminal lawyer can advise you, and can’t tell anyone about what you told him. In addition, a criminal lawyer will get into serious trouble if he ever reveals what you told him to another person. An attorney-client confidentiality means that an attorney can give advice based on knowing everything about your case and situation.