When you start the initial block download with the latest versions of Bitcoin Core, how does your node know that old blocks were valid according to different rules prior to soft forks?
Old blocks in the chain are still valid under the current consensus rules.
In a broad sense, this is because the code will be written to enact rule changes at specific block heights, and thus older blocks will not be subject to said new rules.
To put it differently: the consensus ruleset doesn't just cover what new blocks are supposed to look like, they also cover what the historical valid chain looks like!
Sometimes, specific exceptions are written in, such as is the case with BIP 30.
A soft fork is a change to the Bitcoin protocol that adds additional restrictions to the rules enforced by full nodes. However, these additional restrictions only apply to blocks from the point of activation. Blocks pre soft fork activation aren't expected to meet the new restrictions. These blocks are validated according to the old protocol rules that continue to be present in the code of a protocol implementation (e.g. Bitcoin Core).