transactions – How is a double spend via 51% attack possible?

If a transaction is already mined in lets say block A and has 2 confirmations, how can this transaction be spent again?

My understanding is that for a transaction to be propagated to the network it must be verified by each node, one of the checks is to see if the referenced UTXOs have been spent.

In order to double spend the inputs referenced in this transaction included in block A each node would attempt to verify it but would reject the transaction since the inputs have already been spent and so the double spend attempt would fail regardless of if you have control of 51% of hashing power.

So how is it that these double spends are possible by remining block A in this case?