When they complete a mathematical algorithm, they become eligible to add a block to the blockchain. The validation of a transaction happens with the update of the ledger, or the completion of a block to be added to the blockchain. Then the entire network of nodes can see the updated blockchain and verify what they see.
Miners have an incentive to do this work because they get paid in cryptocurrency for every block they add to the chain.
Thousands of nodes are always competing to complete the algorithms, so it is rare for the same miner to continuously be successful in completing these complex problems first.
The hash algorithms are complex enough that a miner’s rate of success is determined mainly by the laws of probability.
But the more a miner’s computer is capable of, the more chance they have of finishing first and claiming a cryptocurrency payment.
The Bitcoin system continues to offer miners cryptocurrency incentives to perform these tasks despite there being only a finite amount of Bitcoin available for circulation.
New tender is released into the Bitcoin network periodically exclusively through payment to miners successfully completing blocks. So too was Bitcoin’s mining difficulty scale, which adjusts depending on the performance of the network of nodes.