Consensus is essentiel in cryptocurrency and "trust" is at the center of it all.
Basically, when you put your money in a bank, you trust your bank to properly keep a ledger of the amounts you have put in. You also trust it to not give your money to someone else or to delete it.
In a cryptocurrency network, there is no such entity to put your trust into, everyone (every nodes) could write to this huge ledger we call blockchain, so nodes need a way to be sure that what other nodes writes is making sense : therefore achieving consensus toward every transactions wrote into that ledger.
Here is a vulgarized list of mechanisms peoples have come up with :
Proof of Work
The idea is, before writing to the ledger, you must prove that you have worked for it (using computational power). Its done by randomly calculating hashes (strings of characters) using one (or many) computers until you sucessfully generate an hash that is valid. After that you can write to the blockchain and hope you are the first. It is used by Bitcoin and many others.
It is based on real worlds limits to prove that what you write is trustable because it costs a lot of real money to buy 1000's of computers and to pay for electricity, therefore the more you have invested in this network, the more you can be trusted because why would you want to destroy a network you have invested so much in !
Proof of Stake
With proof of stake, the more coins you have the more chances you have to be the one that will write the next block and get a reward (ex: if you have 10 coins and someone else has 100, this person is 10 times more likely to be picked).
There must also be some kind of system to prevent you to create falsy blocks, a way to do that is to freeze your coins when you are the one creating the next block, and if you attempt to take advantage of that, your coins gets destroyed forever. Therefore you are discouraged of hacking the network because you put your coins at stake.
Proof of Burn
With proof of burn, you voluntarily send coins to an address where they are irretrievable, therefore winning the chance to mine coins (proportionnaly to the amount you have burned compared to everyone else).
This proves that you are trustworthy if you are willing to spend short term money in hope of long term gains through the network.
Proof of Capacity
Used by Burstcoin, the idea is instead of calculating hashes constantly, hashes are pre-calculated and stored in huge files on hard drives, those files then acts as a database to search in during the mining process.
Therefore the more disk space you can afford, the more chances you have of creating the next block.
Proof of Elapsed time
This algorithm from Intel uses a trusted execution environment (TEE) to ensure blocks are produced randomly without requiring huge processing power. It is based on a guaranteed wait time provided by the TEE.
This methods is therefore putting your trust in Intel and its technology.
More methods (or a combination of multiple methods) may exist, but those are the main methods used so far.
Unfortunately, all of them favorise individuals rich enough to have an advantage over everybody else. If the point of having cryptocurrencies was to remove power from the hands of banks and peoples in position of power, we can't say mission accomplished yet...
But that's an other topic ! ;)