Your chain of events is slightly incorrect.
When a node receives a tx, they don't immediately apply its effects to their state. They hold it in the txpool, and forward to other nodes.
State changes are only applied when the tx is mined into a block, and that new block is received by the node.
If a tx is valid at the time of broadcast, but something causes it to be invalid when mined, it will still be part of the block. However, since blocks are processed in order, and transactions within blocks are also processed in order, the same invalid result of the tx will occur on all nodes, and they will revert any changes caused by it.
A common example of this is A transferring all of their tokens to B, and also making another tx transferring all of their tokens to C. Both txs are valid, until they are mined into blocks. After that, only the first tx in order of appearance is valid, and the second one fails (but is still included in the block, and still consumes gas for the calculations upto the point it fails at).