These costs are legislative and administrative, having to do with appeals and re-appeals of the sentence before it is carried out.
Those millions are going to judges, attorneys, and hundreds of other people involved in the legal process.
The process of putting someone to death is lengthy and complicated but it probably should be. And it's not at all related to expenditures for what some people would see as a cosmetic or optional procedure, whether that's true or not.
I get that people are sensitive to this issue but for a lot of people this sounds about as absurd as an inmate needing 20k plastic surgery to fix their nose they hate so much that they will kill themselves if they don't get it fixed. That's a dumb example but not everyone in this country agrees that it's a vital procedure.