I think you're 75% correct. The missing 25% is the profit motive from privatized prisons and cheap prison labor.
Text of the 13th Amendment: "Neither slavery nor involuntary servitude, except as a punishment for crime whereof the party shall have been duly convicted, shall exist within the United States, or any place subject to their jurisdiction."
This was the amendment that prohibited the practice of slavery in the United States after the Civil War. Notice the bolded exception, and consider who the United States tends to put in prison a LOT more than everyone else.
Taken from that angle, it starts to make much more sense as to why thing are the way they are. Criminal justice in the United States is deeply warped by profit motive (and, y'know, racism). It meshes nicely with "Get Tough On Crime" and "Zero Tolerance" attitudes: indulge people's gut-level desire to punish wrongdoers and spend effort on scooping people up to exploit, rather than spending effort on improving standards of living or community health.