Hello,
As soon as you chose a payment gateway / payment method, a Payment Intent is created based on this payment gateway. Method createPaymentIntent() is called either in Stripe.php or StripePaymentElement.php.
If you go back and empty the cart, the checkout_step db column is emptied for the order, which allows you to chose a different payment gateway / payment method. But, the Payment Intent is not created again. The same Payment Intent created earlier based on a different payment gateway is still used.
I think we should check if the chosen payment gateway still matches the one configured in the Payment Intent. If not, create a new Payment Intent.
I don't know if this is specific to Commerce Stripe now that it offers two payment gateways, or more generic to Commerce Core.
I have only tested switching Card Element and Payment Element. I don't know yet what happens when you switch between payment gateways provided by different contrib modules.
This is also not supposed to happen often since we're not supposed to let the user chose between Card Element and Payment Element at checkout but pick only one... but in my case I am willing to start using Payment Element on an already existing site that has been using Card Element so far, and I want to be able to switch back to Card Element if something goes wrong.
So if one day many clients report having troubles to pay with Payment Element - which means they will probably already have Payment Intents created with Payment Element - I might decide to switch back to Card Element temporarily so I could face this situation where the Payment Intent is not recreated and still trying to use Payment Element.
As I am writing this, I also realize that if I face this situation one day, the only way for people to be able to change payment gateway / method is to empty their cart. Which I cannot expect them to think about doing. So I'd better create a task that cancels all draft orders (carts) and will force them to start over. Doing such will also make sure the Payment Intent is recreated with the appropriate payment gateway.
Nevertheless, I still think this issue is relevant and we'd better recreate the Payment Intent if the payment gateway has changed since its creation.