If there are two valid, signed transactions that spend the same unspent input transaction (UTXO), only one of them will be included in the block. This is indeed guaranteed by the protocol [1].
[1] https://bitcoin.stackexchange.com/questions/81624/can-two-or...