If a defendant has committed a crime, they would choose to
self-represent to ensure that no one else would know about the
circumstances of their crime. Although lawyers are ethically bound to
not disclose information that would not be in the interest of their
client, the decision to breach this duty would be up to the sole
discretion of the individual in question. In cases where the exchanged
information may used to provide evidence against the client, the
lawyer is compelled to disclose the truth to the courts/law
enforcement.
This is deeply misguided.
Criminal defense lawyers usually represent people who are guilty and there is no ethical problem with doing so, nor does this mean that the lawyer will disclose privileged information that is prejudicial to the defendant in the course of the representation.
The notion that a lawyer would be compelled to testify against his client to the courts/law enforcement is simply not how the system works.
It is true that a lawyer cannot ethically put you on the stand to offer testimony when the lawyer knows that your testimony to the court will be an outright flat lie, and that this lie is your strategy to prevail in your defense, but that is the sole meaningful limitation on what a lawyer can do for you.
However, I can't think of a single instance, in which a desire to defend yourself at trial with a lie has caused someone to represent themselves. Usually, someone with that kind of motive will simply lie to their lawyer as well.
It never makes sense to represent yourself if you are innocent and want to be acquitted of the charges against you.
But, keep in mind that this is a small subset of all criminal defendants. Criminal defendants are overwhelmingly guilty of something. Usually, a criminal defense lawyer works to either exploit prosecution mistakes or lack of knowledge that prevent the prosecution from proving that guilt, or work to make sure that the defendant is not convicted of a more serious crime than the one committed, and/or work to see to it that their client does not receive an unnecessarily harsh sentence when alternatives are available.
In real life, people represent usually themselves, either because they are denied access to counsel (which can be done in a criminal cases where the prosecutor waives the right to seek incarceration as a sentence), or because they are "crazy".
Many people who represent themselves in a criminal cases do so because they want to proudly claim that they committed the crime as a means of obtaining of forum for public recognition of what they believe was righteous action even if this could lead to their death. Many terrorists, domestic and foreign, fall into this category. For example, the fellow committed a massacre at a Colorado abortion clinic tried to do this (if I recall correctly, he was later found incompetent to face a trial and has been committed to a mental institution until he becomes competent, if ever).
Other people represent themselves out of a strongly felt guilt that they feel a moral duty to confess to, even if this means that they will face severe punishment for doing so. One subset of this group of people are people known as "death penalty volunteers" who try to get sentenced to death and try to waive all appeals and post-trial review.
Sometimes they also plead guilty in the belief (often, but not always, inaccurate) that their swift guilty plea when they aren't actually guilty will protect someone else whom they know to be actually guilty.
Other people represent themselves because they have deeply held, but paranoid and inaccurate views about the legal system such as members of the "Sovereign Citizens Movement" who think that if they say the "magic words" that they cannot be convicted and that lawyers are a part of a conspiracy designed to prevent them from doing so.
Another situation that comes up is when an affluent person who is not entitled to a public defender as a result, chooses to represent themselves, usually with respect to a fairly minor charge like a traffic violation that carries a risk for a short term of incarceration, to save money. But, this is rarely a wise choice.
But, unless you plan on pleading guilty or being found guilty at trial, self-representation does not make sense, and even if you plan on pleading guilty, a lawyer is usually worth it. For example, even if the direct consequence of a guilty plea is minor, the collateral consequences of that conviction (e.g. loss of eligibility to work in certain jobs and/or deportation and/or loss of a right to own a firearm) may be consequential and something that a non-lawyer would not realize was happening. Or, maybe you think you are guilty of crime X so there is no point in fighting the charges, but actually, the language of that statute has been defined in a manner that means you are really only guilty of less serious crime Y.