I am NOT talking about double spending. I am talking about this type of scenario:
Let's say address A has 1 BTC balance initially. A valid transaction is created and for simplicity's sake, assume all the balance is transferred to address B in a valid manner.
Okay, now that transaction has been confirmed and A has also received another 1 BTC from some other random address.
Now, what prevents a malicious user, to rebroadcast the old transaction as the same conditions are being met. The input has the exact same balance, the old signature is telling to send the balance to B etc.
Obviously, this would mean it would be the same transaction ID and the network would reject it. So my question is, what is the variable in a transaction that allows you to prevent this type of attack? I can't find any documentation.