Why does the US even need to buy oil? Aren’t they a leading producer
That said, refineries are actually somewhat specialized wrt what kind of crude they can process. The US produces some types of crude in excess of its capacity to refine said crude and has more capacity to refine some types of crude than there is domestic supply.
Note also that the Canadian fossil fuel industry is somewhat intertwined with the US fossil fuel industry. The same is true wrt Mexico, albeit to a lesser extent.