In my homebrew setting, incarceration is a very rarely applied judicial penalty. Prisoners are generally incarcerated only for so long as they are awaiting trial or the application of some other penalty.
As a side note, the most notably long lived PC race in my game, elves, cannot generally survive incarceration. They physiologically require beauty to live the way they require breath or water, and would die after a few weeks of incarceration in a typically dank cell anyway - regardless of the length of the sentence.
Most races in my homebrew, if they thought about it, would consider incarceration to be cruel and unusual punishment. They practice torture, sell criminals into slavery, and use a variety of painful executions, but would consider incarceration about the worst thing you could do to another sentient being.
So the issue has never really come to mind.
To the extent incarceration is practiced, it is practiced as a form of slavery where the slave is likely to revolt or try to escape and as such must be allowed only limited freedom. You would then be locked up to whatever extent you could be locked up and continue to work, and likely chained up at night. In many parts of the fictional world, slavery as punishment is practiced only to redeem a debt, and as such only is intended to extend for a certain period of time. This of course doesn't stop many cultures from working slaves to death, or locking them in a mineshaft until they die, but in either case the term of the sentence would be fixed without regard to the logic of punishment. The ones practicing slavery as a limited term are motivated by the logic of restitution, so your enslaved until you pay back your debt, after which you get your life back. The idea then that a longer lived race would need to pay more wouldn't really occur to them as the debt had been paid. The ones practicing slavery on a permanent basis are motived by the logic of profit. It never makes sense to free you ever, so what does it matter what the length of term is? The advantage of a durable long lived race like a dwarf is you get more labor out of them? Why ever let them go?
I should also note that racism is rampant in my homebrew world, so generally speaking the only punishment you can expect to receive if you aren't the same race as the magistrate is death. If the law doesn't support it, the suspected perpetrator would simply be lynched. Heck, the people doing the killing probably wouldn't even see it as a lynching - they'd just see a monster and well, they'd kill that monster as unreflectively as the average PC kills an orc in a stereotypical beer and pretzels game. In the case of Drow, no one knows that they aren't extinct, and if they did realize they weren't extinct they'd try to finish the job. There wouldn't even be much debate about it. They are monsters: kill them, duh.
As far as laws regarding juvenile offenders, there really aren't any. There is no idea of "trying a juvenile as an adult", because they don't really distinguish legally between a law-breakers on account of age. A judge might, of his own accord, decide to extend some degree of leniency toward the felon on account of age, but quite literally if a nine year old hit another nine year old over the head in the street and took a silver penny from him that he was going to use to buy a brace of hens for his mother, then they would be 'capital highway robbery' and they'd hang the nine year old felon unless some accommodation could be reached or the judge was particularly soft hearted. Accommodation here means that victim isn't particularly keen on pressing for the full legal penalty and is willing to accept a lighter sentence, and the judge thinks that the kid just was a stupid kid that didn't realize the full import of their actions, the kid that was hit over the head is fully recovered, and owing to the relatively small amount of damages, some lesser sentence presents itself as an option. Otherwise, the kid swings and don't be too surprised if gawkers show up and hawkers show up to sell them food to eat while they are waiting for the action to happen. And that's in relatively nice kind-hearted places on the map where they pride themselves on being reasonable and merciful.
So again, the notion that races of different ages needed to be treated differently on account of age wouldn't enter into anyone's head in the way you are thinking. And on account of the aforementioned racism, a 90 year old elf that looks like a 10 year old child would only likely be treated like a child by an elven magistrate. In some parts of the world, a human magistrate might not be able to even realize that that isn't what mature elves look like, as the two races don't often mingle.
I guess my point is that justice in my homebrew has a distinctly pre-modern feel to it. The Code of Hammurabi for example has none of the features you are talking about. They didn't have the wealth to incarcerate people in their leisure and support them and pay people to guard them and look after them and build buildings to house them. If you were dangerous, they couldn't really afford to deal with that. If it was a non-violent property crime, then you paid a fine and if you couldn't you were sold into slavery to cover the fine. And there are no exemptions for age.