There are limits to lawyer-client confidentiality. My understanding is that if a client tells their lawyer that they are guilty of a crime, for example, the lawyer cannot argue that they were nowhere near the scene of the crime at the time or anything.
If there are technical defences still available, for example the client was insane,
or was acting in self defence, or the client’s version of events indicates that they are indeed only guilty of a lesser crime, or the police didn’t follow proper procedure, then the lawyer can fight the charge based on what is available.
Doesn’t mean they can reveal what the client has said to them in confidence, but they can refuse to use arguments or defences that run counter to the client’s admissions.
And if a client reveals plans to break the law in future their lawyer needs to report it.
I’m sure I’ll be corrected if I’m wrong.