Bitcoin uses a special distributed database structure, called blockchain. This structure along with the computationally expensive Proof-Of-Work (PoW) algorithm that Bitcoin uses for validating blocks of transactions, it means that you can't really cheat at Bitcoin.
If a malicious actor wanted to cheat, i.e. alter a past transaction for double-spending purposes, he should have a gigantic computing power (hashrate) at his convenience in order to accomplish this. Because, due to the intrinsic structure of the blockchain, the attacker would not only need to make his malicious change at that specific block but also to redo all computations for all blocks after the one he changed. Moreover he would need to complete this enormous task, before everybody else in the Bitcoin network adds just one more block in the blockchain.
The following diagram graphically explains why you cannot cheat at Bitcoin:
Nevertheless, Bitcoin is vulnerable to the so-called "51% attacks". In these scenarios, a group of actors who command a 51% majority of computing power, turn dishonest and try to cheat the rest of the network. They change past transactions in a specific block and also recompute all blocks after the one they changed. If these actors have the needed computing power to complete all the malicious recomputations in time, they will be creating another chain in the network which, due to larger computing power, will become the longest chain.
This in turn will force the rest of the network either to follow the new and longer malicious chain or change their rules (fork) to create a new chain which will continue the original honest chain.