What is an ex post facto law?
An ex post facto law is one that is made retroactive to punish
an act that wasn't illegal at the time it was committed. For
example, if I didn't wear my seatbelt and wearing one wasn't a law,
but it became a law the next day, I couldn't get in trouble for it
because the "crime" was committed before it was against the
Article I of the US Constitution specifically says this cannot
be done. Laws that don't involve penalties can reference dates in
the past to allow an income tax break or permit eligibility for a
program based on past actions (such as fighting in a war).
The reason the Constitution prevents Congress (and the states)
from writing ex post facto laws is to protect the population and
other entities from government abuse.