How does Bitcoin prevent replay-attacks? How does Bitcoin prevent replay-attacks for P2PKH transactions?

As far as I understand, when a transaction is made to pay bitcoins to another account, the P2PKH script is used.

scriptPubKey: OP_DUP OP_HASH160 &lt;pubKeyHash&gt; OP_EQUALVERIFY OP_CHECKSIG
scriptSig: &lt;sig&gt; &lt;pubKey&gt;


Now, even though I may not know what the private key of the person who sends the scriptSig is, I still know how a valid signature from him looks for this very transaction.

So, if I simply copy the transaction with the same data, the check for the signature should still be all valid. So, if someone pays me coins, what prevents me sending the same transaction over and over again, effectively draining all his coins?
A transaction contains a reference to the output that it is spending from. So all you would be doing is just rebroadcasting the same transaction over and over again. Since transactions are identified by the hash of the transaction, the transaction you are rebroadcasting is exactly the same thing as the one already broadcast, and all nodes will treat it as the same transaction, one that they have already seen.