I think that's being way too charitable.
In a world where people are incarcerated on a scale unprecedented in all of human history, and where prosecutorial success is measured by number of scalps taken, the assumption that this is plain malice designed to let the state rob a few more individuals of their freedom makes much more sense than it all being just a big pile of incompetence and misunderstandings.
"The state" doesn't benefit in any way from locking people up. In fact, it costs them money (both directly and in lost taxes from the lost salaries and wages of those incarcerated).
An argument could be made that prosecutors benefit from higher incarceration rates through the incentives you described. And an argument could definitely be made that private corporations paying well-below-market rates for prison labour benefit.
https://en.wikipedia.org/wiki/Thirteenth_Amendment_to_the_Un...
https://www.aclu.org/news/human-rights/captive-labor-exploit...
We got 800,000 or so right now. Fight unemployment? Lock more people up.