I'm an engineer who has worked for a number of manufacturing companies over the years and I have to laugh sometimes when experts give their etched in stone versions of how something was done at a plant 40 or 50 years ago based on cars they've studied over the years.
I've requested parts for testing or study, then a year later been doing some housecleaning and find parts I didn't use. So I return them to the plant where they are put back in inventory and used on the line. I'm sure that happens all the time, so anyone saying parts should be datecoded within a month or two before a car was assembled are talking about how it typically was, but there were many exceptions.
I now work for a truck manufacturer, and sad to say, but many trucks roll off the line and have to go to Test and Tune or as we call it, "red tag", where they sit for weeks or sometimes months before they get repaired or sometimes a missing part is finally received and installed so the truck can be delivered to the customer.
Same happens with cars, probably since Henry Ford developed the assembly line.
But unless you can document it, there is no way to prove a part datecoded after a build date was original. You can argue to death that it "could have been" but there is no way to know for sure. I can go into one of the systems at work and check a truck by order number or VIN, and see if it was red tagged, and why. Records were surely kept back in the day, probably handwritten or printouts, but they are surely gone now. So again, no way to know decades later.
In the case of engines, I wonder what would have happened if an engine was bad on a newly assembled car and had to be replaced by the mechanics in a car plants "red tag" department. Would they have to stamp the VIN on the new engine they are installing, or would it have been blank?
I don't know the laws, but suspect the automakers are required to have the VIN on the engine of cars they build regardless of whether it was installed on the line or installed in the repair department before the car could be shipped.