One thing we should probably point out. All courts/jurisdictions have an obligation to provide counsel for the indigent.
Some jurisdictions have an actual office, like the DA, called "Office of Public Defender" or similar, that hires and pays lawyers like a law firm to represent indigent defendants.
Others appoint counsel on a case-by-case basis, the lawyers volunteering to put themselves in a pool of counsel for this purpose. Some out of charity or public service, others from desperation to turn a buck.
The former tend to be more formally referrred to as "public defenders" while the latter tend to be called "court-appointed counsel." Like everything else, quality varies immensely, but I think the "public defender" type system tends to provide better defense than "court-appointed counsel."
Public defenders usually have hideous caseloads, but have training, some interest in the job, some accountability for results, and their salary isn't tied to volume or dispositions. The others may just be a judge's brother in law.