In this mode, the miners must code the information of the transactions that have not yet been verified with a hash function, which results in a string of a fixed number of characters that is not predictable.
Miners must achieve that the result of the function meets certain conditions defined by the network, and for this they must add a random number (called nonce) to the transactions information. As the result of the hash function is not predictable, the miners must repeat the operation many times, changing the nonce every time, until achieving a result that meets the conditions demanded by the network. The first miner who achieves it wins the right to write transactions on the network and generates a reward for himself.
This process is repeated constantly, with a defined period in each blockchain (about 10 minutes in the case of Bitcoin and about 14 seconds in the case of Ethereum). This period is called block time.
As the network of miners grows (accumulating more computing power), it takes less and less time to find the solution and the block time is reduced, with which the timeline for issuing the currency is altered (because each time a block is processed, coins are issued to reward the miner). On the other hand, if the network loses computing power, the block time becomes longer, and this affects the stability of the network because transactions take longer to process.
To avoid this, networks periodically adjust the conditions that the hash function must fulfill, in order to keep the block time constant. In other words, the network makes adjustments of difficulty to keep the block time constant before the possible growth or decrease of the mining network.