Employment by the US company:
They're allowed to employ you and have you "stationed" in Germany. You pay no US tax, and DE tax on 100% of this income. For Sozialversicherung, Rentenversicherung etc it's just as if you were selbständig. Since you're allowed to give up all sorts of rights in DE conteact Law, the US based contract is probably fine.
Contractor for the US company: this is OK too. Since the company does not have a DE presence they can't run afoul of the Scheinselbständigkeit rules. You really should register as a Gewerbebetrieb, GmbH or English Limited company though, as that solves a lot of tax questions for you. In any case as a selbständiger in Germany You should expect to get audited in the first few years... And this makes it less likely they'll find things you have to pay.
I am not a Steuerberater... But I've been in a two selbständig household in Germany for 7 years. My income was from international tech contracts, just like yours. And I went through a Steuerprüfung, where they decided that since I dont have a degree in CS, I can't be selbständig in that field. Didn't matter that I have a long resume of big organizations, and a letter of reference from the CTO of one of the biggest companies in Germany. I had to form a Gewerbebetrieb and pay back taxes for it. It sucked.
Also, good luck on finding a Steuerberater who will help you optimize at all. Technically tax optimization is illegal, so most are very cautious even talking about it. 99% are just form fillers.