Wow... lots of numbers, all wrong unfortunately.
1) Prices for in the PHB are for players only. This is to avoid a barter fest with each transaction. I can see why you assume that between NPCs it would be so. But it was not generaly the case.
Many of the prices I used were from the DMG and the Adventurer's league official numbers as well. But, you can't just declare that the prices are different than the source material because player's don't barter. Besides, if you can just decide prices are lower, I can just decide that they are higher. We need to use the official materials to have a discussion at all, instead of just a game of calvinball.
2) Historicaly, specialist were paying their due with services (otherwise they might migrate to a rival barony/country or whatever). The materials were paid by the "crown" but the actual work was free.
So, you want the crown to shell out 6,000 gold in materials for a few single use items, so that the wizard can pay his 9,000 in taxes, meaning they only make a profit of 3,000 gp in value... again for single use explosive death for petty pickpockets and drunks.
This is INCREDIBLY poor management of resources.
3) Yes knights were costly to maintain. And guess what? So were soldiers. All their basic expanses were paid for. But the wonder of the medieval system was that many knights were themselves, product to be leased (free of charge) to the king. So were armies. A lord would pay for his army and part of that army would work for the Count, then the Duke, then the King and so on. The knights/soldiers will not get paid for each weapon swings/arrows fired. The same will be assumed for casters. This is only logical.
So, you aren't actually paying attention to WHY I mentioned the knights. You said that the wizard was doing this magic to pay his taxes. This was your claim. I am merely pointing out that if you are right, then using some basic numbers and looking at a reasonable measure of importance in terms of knights, the wizard is likely ONE OF THE WEALTHIEST AND MOST POWERFUL PEOPLE IN THE KINGDOM. You would essentially be having the King's Uncle going to Mudville to set a trap for a pickpocket.
Now, if you are shifting your argument, because you find your original argument to be untenable, then it would be polite of you to say so, to eliminate confusion.
Cold will not affect the cells.
Extreme sudden cold like what is caused by a spell could very easily cause thermal contraction and shatter stone.
Also, I double checked the DMG, stone walls are not listed with "immunity to cold". Yes, it does say to use your best judgement, but like I mentioned, thermal contraction can shatter stone. It can even more easily shatter steel that has been buried in stone, you know, like the bars of the cell.
Spells that will deal necrotic damage: Inflict wounds (some casters can be clerics you know and an upcast is always possible), Blight for Arcane casters (nothing prevents the caster to be a bit higher). And we could add even more, but you see the point.
Note that I continued talking about wizards, the original example, so I didn't count clerics. Yes, if you decide to change it from a wizard to a cleric, then you may be able to have necrotic damage. Thinking about it though, how many taxes did the church pay in medieval times? Oh right, they tried to pay as few taxes as humanly possible. And considering a 5th level cleric can raise a dead knight saving the kingdom thousands of gold... I think they'd prioritize healing and raising the dead for their taxes instead of trapping cells for pickpockets.
I could have assumed that instead of a 5th level wizard we had an 8th level wizard who casts two fourth level spells which would cost them ~750 gp instead of the 550. I figured not doing so was a kindness.
Also, the spell would not destroy a cell, damage yes, but it could quickly be repaired with a simple mending or even stone shape.
Sure, more magic is always an answer. It just increases the cost of this entire endeavor though.
You might see this a forced labor and in a modern point of view, you would be right. But imagine yourself in a country where monsters, and evil countries exists and you will see it differently. This becomes a matter of survival as doing such minimal work for the crown also enhance your own security. Who knows? the spell you cast for your king might prevent a spy from a rival evil empire (and this time, it might not be a perceived evil, but a true one. Iuz comes to mind here).
And you might add:" But the caster will have less spells to defend himself!" Well both yes and no. The lord would and will provide guards to protect the caster while working for him/her. That's at least what any sensible lord would do.
No, I'm thinking "pickpockets and drunks aren't spies". This is a level of paranoia and extremism that I find utterly bizarre.
Also, wizard accademies (especially war wizard ones) would work exclusively for the king. This means that they are expensive, yes, but such an accademy will provide such services for almost free (the basic cost of the spell, nothing more) all year round! Temples will also provide such services for free (save the costs of the spell itself) just to keep the right to stay in the country, or to be the official state religion, or simply to avoid taxation of their own property. And again, the service will be seem by lawful churches as a necessary cost/work/service to ensure that Law is upheld and thus furthering the goals of their ethos.
And for a barony, the court wizard will do these services year round for absolutely free! Well, the wizard will need the material components, but these will be already provided by the baron/count/duke or whatever. Even the local church will be put to contribution if the local priest is high enough.
Absolutely free, except for the thousands of gold spent on materials. Again, not for the most important cells of the kingdom, not for the king's maximum security prison, but for every village in the entire region.
Don't you know that the entire point of a maximum security prison is that they are MORE secure than the local village prison? They don't get the royal academy of wizards securing their cells. They are lucky to have stone and steel to make an actual jail cell.
Though I suppose they could use stone shape and wall of stone to make every building in the kingdom from stone. Wizards work for free after all.
And again, you are entirely free to do it the way you do it. But that does not invalidate my point by one iota. I encourage you to check BECMI cyclopedia for the rules of services in it. The old DMG 1ed also had some good notes.
I think the rules for 5e are more relevant for talking about a 5e game. If you were playing a 1e game, then that BECMI table might be more relevant, but that isn't the case.