How does mining work on the moving target (variables change every second)?
Realistic miners run through all 2^32 possible nonces in much less than a second.

If a transaction occurred after you started your nonce search, then your block won't include that transaction. There's no problem with that.

If the time changed after you mined your block, then your block won't have the exact right time. Again, no problem with that.

And if you think about it, there can't be any problem with that. How would anyone know when you mined the block or whether the transaction occurred before or after you mined the block? It's mining that allows bitcoin to agree on these things, so if you mined the block, you're the one who gets to choose.