Because the US is the sole guarantor of German sovereignty. It's why the US has tens of thousands of troops in germany. It's why US decides if and how much oil/gas Japan or South Korea gets from Russia. It's why the US decides if the Dutch get to sell ASML semiconductor equipment to China. It's why the US dictates whether Canada arrests a chinese executive. Pax Americana. Protection doesn't come cheap. It certainly isn't free.
> Image if it was Germany that used sanctions to prevent the US from building a pipeline to Mexico. Would you be ok with that?
Of course not, but germany is in no position to dictate anything to the US. That's the point. If germany had tens of thousands of troops stationed in the US and provided safety to the US and mexico was germany's enemy, then germany would prevent the US from doing business with mexico.
I'm not saying it's right or moral. It's just basic geopolitics. If you depend on another nation for your safety and host tens of thousands of their troops in your country, you are really not a sovereign nation and hence don't have the luxury of making all the decisions on your own.