No problem.
"Whoever, being a citizen or subject of any foreign state, is found and taken on the sea making war upon the United States, or cruising against the vessels and property thereof, or of the citizens of the same, contrary to the provisions of any treaty existing between the United States and the state of which the offender is a citizen or subject, when by such treaty such acts are declared to be piracy, is a pirate, and shall be imprisoned for life."
Yep, one long sentence.
The part you quoted seems to refer to acts of piracy against US citizens.
"upon the United States"
"or cruising against the vessles and property thereoff"
"or of the citizens of the same" (I'm taking "the same" to mean US)
So, anyone found and captured on the sea while raiding US citizens can be imprisoned for life as a pirate.
In other words, the hijackers could be considered "pirates" (allow air instead of sea), but the other people in Afghanistan wouldn't be.