If someone committed an act which was illegal at the time and is now legal, they should be freed.
If someone committed an act which was legal at the time and it is now illegal, they should not be prosecuted.
They're not two sides of the same coin at all.
EDIT: This compassionate principle is known as "lex mitior", which simply means that you should apply the mildest version of the law (from the perspective of the accused) in these cases. This is also in line with the widely accepted innocent-until-proven-guilty principle.
> Congress is prohibited from passing ex post facto laws by clause 3 of Article I, Section 9 of the United States Constitution.
https://en.wikipedia.org/wiki/Ex_post_facto_law#United_State...