The state’s prison population has been rising for years, and the system is now over capacity by thousands, leading to millions more in expenses annually.