Since the crank and cam position sensors read every tooth plus the spot where there is no tooth, the ECU knows exactly where the engine is at all times. The ECU loop time is likely in the 1 msec range (or better) for read and respond. Now consider a Chevy crank sensor with 53 teeth - so every 6.8 degrees plus TDC. Add in the cam sensor and you know where in the stroke each piston is to within 6.8 degrees. Actually better, since you know the rpm as well, and can estimate within that 6.8 degrees. At 5000 rpm, engine fires a cylinder every 3 msecs. So you have a very accurate picture of where every piston is in the 4 strokes and plenty of time to control it.
Now consider sequential fuel injection. The precise amount of fuel is injected into each intake port a the precise time for each cylinder. The timing of that injection is very importance to horsepower and emissions. Sequential injection made more HP than batch fire injection. Now we have direct injection. The timing is even MORE important and the results are again more HP and fewer emissions. I used injection to show how fast the ECU needs to be (and IS) to make it clear that the ignition timing is pretty easily controlled to that level of precision as well.
Each spark advance can be adjusted in real time, every stroke, to maintain a low, smooth idle. Since emissions are regulated not as a percentage of the exhaust but the total amount emitted, This favors small engines for obvious reasons as well as explaining Stop/Start systems. A low idle makes meeting the standards easier even with a large engine. Also stopping the engine at the “best” point to re-start using Stop/Start systems uses that info, too.
As for state emissions checks, they don’t have the necessary equipment to measure all the things required by the regs. They are just taking a snapshot to prove the car is still in compliance. Some states don’t even use tailpipe sniffers or a roll test, they just look for the CEL.