Tesla’s profits are often driven by the sales of carbon credits, not so much cars. It’s fair to point that out. He sells billions of dollars of them. I’m not even exactly sure how it works but he gets credits for each zero emission car and since he doesn’t make ICE cars he doesn’t offset them, they are just surplus which he builds up and sells whenever he needs to plug a hole in quarterly results. He didn’t invent the program but it exists so he might as well take advantage of it.
The carbon tax that refineries pay (or receive if they make ethanol) is called RIN: Renewable Identification Number. It was originally conceived as part of the ethanol formula. But it has sense morphed IMHO to being a war on gasoline to punish refineries for making too much gasoline (a cost passed onto consumers).