The US sanctions the PKK because we're obliged to do so by our NATO ally Turkey, which gave rise to the PKK by carrying out a genocide against its local Kurdish population.
Meanwhile the SDF, the armed wing of the PYD, follows the same ideology as the PKK and was trained in military tactics by the PKK, and was among our chief allies against ISIS. They fought alongside US soldiers and we even supplied them with small arms.
The history of the PKK is complicated and the state they struggle against has a long history of genocide and (more recently) outright dictatorship. The relation of these countries to the PKK isn't ultimately determined by the PKK's history, morality, ideology, or even the use of terrorist tactics per se.
If you're curious about the bigger picture, there's actually an organized movement whose aim is to "de-list the PKK" as a terrorist organization, and that's probably a good place to start: https://www.peaceinkurdistancampaign.com/activities/delist-t...
There are also some books and some academic papers on the history of the PKK and their ideology. Those written by independent academics are generally neither fully condemnatory nor exculpatory towards the PKK, but give a clear sense of how the term "terrorism" and its use is at least contestable, geopolitical, etc. And any familiarity at all with the history of the conflict makes it clear that the Turkish government is likewise guilty of state terror conducted against Kurdish civilian populations in Turkey for generations now.