They are planted in graveyards in the UK, it prevents grazing animals from entering and soiling up the place. The animals seem to know to keep away. They cant nibble the grass without getting a mouthful of the needles.
Here in the US the most common large wild grazing animals are deer, which can quite happily eat yew.
I hear Yew is uniquely poisonous to horses (I mean, they are especially susceptible to it)
I’ve heard a different reason for their presence in graveyards: because yew kills grazing mammals that eat it, it was cut down everywhere that people grazed animals, which excluded graveyards