They literally have no way to do so. There is no tool in the toolset to distinguish a cart someone else bought at the store from your own carts you bought at the store and then moved from a Switch 1 to a Switch 2.
This is absolutely not true; it's absolutely possible and even suspected that individual game carts themselves are signed with unique serial IDs or even full certificates or cryptographic signatures.
I think it's more likely the previous owner did dump the cart on to a MIG Switch or similar ROM cart. While the NS1 cannot tell the difference; it can still be updated to do so.
I think it's likely that in order to play titles online; your Switch 1 has to get the Cart Serial number from the cart and package it all up nicely and sign it neatly with the certificate from the system. So if said Nintendo Switch 1 already transferred that title out to a Switch 2, then there would be a record on file with Nintendo saying "NS1 with Serial XYZ transferred Title cart ABC with serial DEF to Switch 2 with serial GHI". Then when you put that cart into a different Switch 2 it notices and informs Nintendo of the new title and cart serial...which then immediately picks up on the change of ownership.
That might not raise red flags if you handed the cart over to your friend next door; but it certainly might raise red flags if you air-mailed the cart over to your buddy a few countries over.