I don't know the law but logically the idea is like piracy. You see a pirate on the high seas you can shoot him. Even if he is your citizen. Piracy was an asymmetrical-war like crime that was very hard to eradicate, was more organized than most criminals but not a sovereign state where you could ambush their troops on sight if you had declared war. So they decided any country could shoot them. Piracy is just like terrorism in those regards. At least they don't assassinate terrorists inside the US, we like to not be like Somalia.