If you simply follow the basic compassionate principle that you should lock up as few people as necessary for as short a time as necessary to maintain the law then the answers are obvious for both cases:
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.
I don't see them as the same at all. If something is made legal, it indicates that the act is OK and that the person should not _continue_ to be punished. On the other hand, people should only be prosecuted for acts that were illegal at the time they were committed - it isn't equitable to prosecute people under laws they were not subject to at the time of the action, and even on a practical level it is necessary for maintaining trust in the law.
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.