Giraffes have evolved long tongues for a couple of reasons, both related to their diet:
Reaching high leaves: Their incredible height, thanks to their long necks and legs, allows them to reach leaves that other animals can't. But their tongues give them an extra edge to reach even the highest, most tender leaves on their favorite trees, like acacia trees.
Maneuvering around thorns: Many of their preferred food sources, like acacia trees, have sharp thorns. A long, agile tongue (called prehensile) helps them pluck leaves selectively while avoiding getting stabbed. Their tongues are also tough and thick to protect them from scratches and thorns.