Let's say a person is convicted of a crime and incarcerated. If it is found afterwards that at the time of the crime he was not yet 18 (or whatever is the age of maturity in that system), and that he turned 18 two days after committing the crime, is he still held responsible? What would happen to that person?
The conviction would be vacated and the person would be retried as a minor
The first conviction was undoubtedly an error of law and would be a void decision at common law. The person is then eligible to stand trial as a minor, whether that is in the interests of justice is a matter for the prosecutor to decide.
Specific statute law in specific jurisdictions may give a different result.