The agencies that administer prisons get their funding from taxes, and the the level of funding maybe based on population.
But ultimately, society (taxes, etc.) pays for it.