I asked a question about marking trails and one of the answers suggested nailing markers to the trees. Does this damage the trees? I'm mostly concerned about long-term infection or rot that will eventually kill the tree.
It can hurt the tree, and allow disease to enter through the hole. The other reason not to use nails in trees is for humans, cutting into a nail with a chainsaw can be dangerous.
It probably won't kill the tree right away, there are living trees in Yosemite that were marked with large blazes by the Calvary in the early part of the 1900s and that didn't kill them.
Trees can be remarkably resilient. As explained by Davey, a tree care company:
Healthy trees are tough, and when they’re drilled with a nail or screw, they’ll start a process called compartmentalization, which means they naturally heal the area around the wound and protect the rest of the tree from potential infection. So, for the best stability, choose a healthy, strong tree.
This is why tapping maple trees for syrup each year leaves virtually all of them completely healthy.
There is a more practical reason why putting nails in trees is frowned upon, and that's because of dangers that can arise when felling or milling them after the tree has grown around the metal fixture.