Your wallet itself doesn’t delete or spent any bitcoins.
It rather verifies/spends a UTXO.
If your transaction isn’t confirmed it simply means that you are still in possesion of that UTXO/( that the UTXO hasn’t been spend yet), which means you can simply rebroadcast it to another adress if you’d wish to.
As the network ( rightfully) thinks the money is still in your possesion.
The transaction ID that gets confirmed first will be valid, and your other broadcast that spents the same UTXO’s ( or partly the same UTXO’s) will be invalided automatically ( as the coins have already been spent).