How does Shopify get away with charging fees on a cancelled transation?

Because it isnt Stripe. Shopify Payments makes their own rules and acts as
their own processor. They might say they partnered with Stripe, but I think
Stripe just provided the processing tech. Your charges aren’t actually ran
through Stripe. Shopify Payments is it’s own entity and setting these fees
and charges as they see fit and/or for profit.