When does a node mark a transaction as confirmed or unconfirmed? As new transactions are broadcasted, the nodes keep them in a pool of unconfirmed transactions.

One node will add it to a block as soon as it finds a proof of work. At the same time many other nodes are working on the same transactions. When a new block is broadcasted to the network, it should either be marked as confirmed or removed from the pool.

I have a few questions about this process:

1- how the other nodes know the new block is already created so they should stop working on it? (or they don't?)

2- when a new block of transactions are added to the blockchain how the other nodes know they should not consider that transactions in their next attempt? They read the node and mark the transaction as confirmed of remove them? Is there any other kind of message they exchange?

3- if 2 new blocks are added to the blockchain in different branches. the first branch as active because that block came first. a new block arrives and the second branch is discarded. what happens to the transactions in the discarded branch? they are already in the other two blocks of the blockchain for sure? what do the nodes do with them?

thanks!
They don't know about the new block until they receive it over the peer-to-peer network (or some other way, e.g. FIBRE).  But since it was broadcast to the network, and all nodes on the network will be trying to relay it to all their peers, this should happen pretty quickly.
When they receive the block, they know to exclude those transactions in their own blocks.  (In practice, they probably generate a whole new candidate block, including only transactions not already confirmed, and with a new header that lists the just-received block as its parent.)
When the node changes its mind about which branch is active, transactions from the previously active branch (subsequent to the block where they diverged) are returned to the memory pool, except for those which are already in the new active branch, or conflict with a transaction on that branch.  Then, just like all other transactions in the memory pool, they are eligible for inclusion in future blocks created by this node.