How does the hash of a coinbase transaction differ for the same miner? Based on the format of a coinbase transaction described here: What is the format of the coinbase transaction?, I don't see how the all the coinbase transactions for a given miner do not all have the same hash assuming the miner was just using a single pubkey and the block rewards were the same. If they all have the same hash then when you spend one of them, you effectively use them all because that transaction hash has now been used as an input. Clearly that wouldn't make sense, so how are they ensured to be unique transaction hashes?
The script of the input to a coinbase transaction can hold up to 100 bytes of arbitrary data. After BIP 34, the block height must be the first thing in that script. Since each block has a different height, this rule ensures that each coinbase transaction is unique as the block heights will always be different.

Furthermore, since miners can put whatever arbitrary data they want in that input script, they frequently use that as an extra nonce. Instead of reselecting transactions when all of the nonces are exhausted, miners will increment a value known as the extranonce which is put in the input script.



Also, before BIP 34 activated, there were in fact cases of identical coinbase transactions in different blocks. Only the outputs from the most recent of these identical coinbase transactions are spendable. Spending outputs from these transactions does not spend all of the outputs, only the ones from the most recent one. This means that the outputs from the earlier coinbases are unspendable and those coins are provably lost forever.