Miners offer up blocks to the network hoping that their offerings will be accepted. Other nodes may accept or reject such blocks. A node that accepts a block adds that block to their copy of the blockchain. Nodes that don't accept a particular block don't add it to their copy of the blockchain and don't pass on that block to anyone else. Any miner that is consistently a source of bad blocks is likely to be ignored thereafter.
Miners can't spend income from a block until a further 100 blocks have been added on top of their block. So miners have a great incentive to only offer up blocks that are acceptable to everyone.
All nodes validate blocks and the transactions in them. This consists of checking that the blocks and transactions conform to a set of common rules. These rules are often called the consensus rules. The rules protect the interests of the buyers and sellers in transactions.
Nodes will eventually be ostracized if they consistently apply different rules and attempt to pass on blocks that meet their different rules but don't meet the mainstream rules.
All nodes called "full nodes" do check hashes and perform cryptographic checks on signatures. Some nodes (Simplified Payment Verification or SPV nodes) rely on other nodes to do much of this work, but they will still perform some checking themselves.
The classic example of an illegitimate transaction is one that attempts to spend money that has already been spent in a prior transaction. A trivially illegitimate block would be one whose independently calculated hash is greater than the current target value (inverse of difficulty)