What if a miner takes a transaction which is already on the chain and adds it to a new block to earn the fee once more?
Which mechanism prohibits replay attacks of this type?
Transaction inputs use Unspent Transaction Outputs (UTXO).
UTXO are created by transactions. They are uniquely identified by the transaction id and the output position in the transaction that created them.
Once UTXO are used as inputs in another transaction, and that transaction is included in a block, nodes that parse the block will mark them as spent.
So any node evaluating the replay attack will realize that the UTXO are no longer in their UTXO set and therefore the funding for the transaction is invalid.