because there's a war coming soon that will destroy most global trade. trump wants the US in a better position in that near future by having more factories and such inside of the US.
in a peaceful world, you allow free trade and specialization to do its thing and everybody gets richer. you farm bananas, i farm apples, and we trade. we create value out of thin air, it's an amazing thing.
but in a world where superpowers are at war and the world splinters into factions, half of the global economy will be cut off from the other half. therefore it'll be a huge liability if we for example depend on Taiwan for 90% of our computer chips when China can blockade Taiwan and we cannot reliably break that blockade. that's one industry.. now imagine the thousands of other products we need for a modern economy. it would cause massive economic shockwaves.
so this tariff thing is accepting that this will happen in the near future and preparing for it, slowly weaning off the economy from that connection to the rest of the world. so when it does come, it doesn't hurt as bad.
it doesn't really matter if you piss off your allies. since you're the biggest military power they are going to have to rely on you anyway. you have leverage over them. the difference is that Trump is a reality TV star and so he is loudly exploiting this leverage whereas most past leaders would be more subtle and diplomatic about it.
Canada, Mexico, Germany, Japan, etc aren't really allies. Being someone's ally implies there's a sort of equal footing. When someone has no choice but to bend to your will, is that a voluntary relationship? the US essentially wrote Japan's constitution and they told the Germans what to write down for theirs. Canada and Mexico are heavily dependent on US trade- US growth might slow a half percent or two whereas Mexico and Canada are liable to fall into a recession because of these tariffs.
it isn't equal footing. it's a david v goliath situation
to give a recent example, Ukraine. Ukraine in 2014 had the Euromaidan coup and the president had to flee the country. The new government that was quickly appointed without an election realized one thing very quickly- Russia was about to invade them. they had only one option in terms of getting military aid and that was the US. so immediately, the same day that the government was appointed, they started cooperating with the US. a few days after that, little green men showed up in Donbas and the Russian army waltzed into Crimea
so you can say they "allied" with the US but a more honest way to say it is that they were desperately pushed into America's orbit. and the US ultimately doesn't care about a country like Ukraine. people are starting to see it more clearly today because of Trump, but I honestly don't think the situation would have been meaningfully different with Biden or Kamala. The primary difference would have been rhetoric. Instead of calling Zelensky a dictator, we would have just dragged our feet with military aid instead, like what has been happening the last year or so
tldr: the US is a imperialist superpower and this is what they do.