Blockchain consists of blocks which are linked by cryptography. Every block records all the transactions and the chain of blocks are connected in chronological order, forming the digital ledger better known as blockchain.
Using Bitcoin as an example, when miners generate a new block, it must be based on the previous block’s hash, transaction data and nonce, to derive the new hash and nonce. This means every new block is generated based on the previous block, ensuring the integrity of the blockchain data.
Even the slightest alteration of the transaction record will result in an entirely different hash, hence, miners can’t cheat during the mining competition. They can only mine the next block after the previous one is generated as they won’t have the data to start mining for the next block, ensuring the fairness of mining.