How does a node decide whether a block is valid?
Blocks cannot be modified because the next block contains a hash of the previous block's header. Any change to a block would result in a change to the header, and thus, change its hash, requiring all blocks which succeed it to also be modified because their hashes would no longer be valid. It isn't possible to rebuild all of the blocks because it requires work to compute valid hashes (they must have nBits leading zeroes in their merkle root).

Blocks are correct only if they are in the longest known chain with the most accumulated proof-of-work. Meaning any chain with less work than the longest known chain is invalid.

If a node sees a valid block X but then later, receives a new block Y, where YHeight &gt; XHeight, and the chain of blocks up to #YHeight does not contain the block X, then X is discarded. Only the blocks in the longest chain are treated as valid blocks.

This is also true in a tie. If two blocks are mined by different miners at the same time, each participant assumes that the first block they received is the valid one, and they continue the Proof-of-Work process from this valid block. The next miner to create a valid block ends the tie by creating the longer chain, and any miner who was working on a block other than the one referred to in the new block's header will discard the work they have done so far on the shorter chain, and continue working on the longer chain.