Is that how it worked with Iran Contra prosecutions?
Ollie North was tried in 1988. Reagan was still in office then. So Ollie North was prosecuted by the Reagan DoJ. And Reagan was followed by another (sort of) Republican administration, Bush I.
But the Clinton Administration that followed Bush I did not further pursue it.
So yes, that is how it worked in the with Iran-Contra affair.