What prevents miners from mining more bitcoin after 21million btc was mined?
The Bitcoin protocol allows block authors to create a limited amount of new bitcoins in the outputs of the coinbase-transaction (which also collects the transactions fees) in each block. The amount of the so called block subsidy is limited by the consensus rules.1 Creating more than the allowed amount makes a block invalid to other Bitcoin nodes.
Each full node unilaterally enforces the consensus rules. This means that while a miner would be able to create a block that breaks the consensus rules, every other full node in the network would recognize it as invalid, drop the block, and ban the peer that sent it to them.
A change in the consensus rules that allows blocks that were previously considered invalid is called a hardfork. Hard forks require social consensus of the complete ecosystem or will cause a split of the network as each node operator determines for themselves which software to run. Even if a majority of the hashrate and a majority of the network's nodes hardforked to a new version of the Bitcoin protocol that allowed blocks with a higher block reward, the remaining nodes enforcing the original consensus rules would consider it invalid and continue to follow their own rules. Therefore, an intolerant minority may be able to veto a hardfork, especially if this minority has a significant share of the economic weight. If the economic majority prefers the original rules, miners following the hardforked chain may find it difficult to sell their mining reward. This is essentially what happened in the case of the SegWit2x hardfork attempt.
In the case that both protocol versions have some economic support, a persistent fork may be calved in the form of an airdropped altcoin. This is essentially what happened in the cases of Bitcoin Cash spinning out from Bitcoin, and Bitcoin Cash calving Bitcoin SV.
1 The block subsidy started at 50 bitcoin per block and halves every 210,000 blocks. We're currently in the third era where miners are allowed to create 12.5 bitcoin per block. Having recently passed block 600,000, more than 18,000,000 bitcoins have been found already, and the next halving to 6.25 bitcoins per block is coming up at block 630,000 in spring 2020.
When a miner find a valid hash he had to write the new block according to the bitcoin protocol rules, if he try to cheat, like writing that instead of the 12.5 bitcoin that issued to the bitcoin miners (him) it is 50 bitcoin, the network will refuse and ignore this block till he write it properly or someone else write it with the good hash and the right rules.
So in your case the protocol said that there will be no more bitcoin issued after the year 2140 if the protocol does not change, a winning miner have to be careful to follow the rules when he issue his block or he can loose his coins since another will see the winning hash but not the proper block, so he will write the block himself with the winning hash and the proper rules and take the coins for him.
Bitcoin block reward gets cut in half, mathematically limiting the reward. This happens every 4 years, roughly speaking. The block reward hits 0 when the amount mined is 21 million. The reward keeps declining until this happens.