Of course—and it wouldn't make sense to expect the law of the United States to apply to foreign citizens.
Here's where I'm getting confused: if the laws of a country do not apply to someone who is not a citizen of that country, why do the laws of the United States let the US spy on non-Americans? (Or any other country, for that matter)
Because a country is sovereign. It can do whatever it wants unless it steps on the toes of another sovereign actor at which point a diplomatic incident ensues. But by default a state is the highest human authority so it doesn't need permission to do anything.
Right. Sovereign states exist in a state of anarchy. They can do whatever they want, and the only ultimate way for one state to stop another is through force.
Of course, this is the traditional Westphalian model that is beginning to cede to voluntary associations of sovereign states that solve their disputes in freely associated bodies, e.g the WTO, the United Nations, the International Criminal Court.
These bodies really ultimately have no binding authority except that granted to them by the states of which they are composed, but reciprocity and social norms are starting to give us a ladder out of pure anarchy. That's really been the project of international relations of the twentieth and twenty-first centuries.
Here's where I'm getting confused: if the laws of a country do not apply to someone who is not a citizen of that country, why do the laws of the United States let the US spy on non-Americans? (Or any other country, for that matter)