That’s not strictly true. No more than the statutory maximum that was in situ at the time can be imposed (ECHR Article 7) but (despite what Sun and Mail readers would have everyone believe) sentences for sexual offences have gone through the roof in the last 30 years, so someone being found guilty of historical sexual offences from, say, the 1980’s will be subject to a far tougher sentence today than they would have been if they’d been convicted at the time. Up to three to four times as much, up to that statutory maximum, isn’t unusual.
Whether that’s unjust depends on the offence imo. A bit of non-consensual groping of an adult in a public place should not be dealt with more harshly than it was at the time imo as it was much less socially unacceptable a generation ago, whereas anything that involves kids or rape has never been ok in post-industrial times and should therefore be punished as per today. I think it’s wrong to impose our own sense of morality upon people who have previously faltered in a relatively minor sense - although as it’s a largely pragmatic view, as a philosophical position I’m not entirely sure I’m on totally solid ground as it’s arguably philosophically inconsistent.