The avocado's name has been bent by at least two languages that half-heard it, and its most famous "fact" is mostly wrong.
The source is Nahuatl, the language of the Aztecs, where the fruit was āhuacatl. Spanish speakers took it as aguacate. Some then reshaped it to sound like avocado, an existing Spanish word meaning "advocate." Etymonline says that word comes from the same Latin root as English advocate.
English had its own trouble with the word. Wikipedia gives the earliest known English use as "avogato pear" in 1697, later "avocado pear" because of the fruit's shape. Etymonline dates avocado on its own to 1763. It dates "alligator pear" to the same year, an English garbling of Mexican Spanish forms such as alvacata. The fruit ended up with a lawyer and an alligator in its name, and neither has anything to do with it.
Now the famous claim. Many articles say āhuacatl meant "testicle" and that the Aztecs named the fruit for its shape. The anthropologist Magnus Pharao Hansen, quoted by IFLScience, says every text he has found uses the word for the fruit. He adds that he has never met a Nahuatl speaker who took it to mean anything but avocados.
The testicle gloss appears to trace back to Frances Karttunen's Analytical Dictionary of Nahuatl, first published in 1983, which translated the word as "avocado, testicle." Karttunen drew on Alonso de Molina's 16th-century Nahuatl dictionary. Hansen suggests the body-part sense was a euphemism based on resemblance. He compares it to English "nuts": nobody would claim that "nutcase" literally means a box of testicles.
That is roughly where the dictionaries have landed. Wikipedia says the original meaning can be reconstructed as "avocado," though the word seems to have been used in Nahuatl as a euphemism. Etymonline lists "testicle" only as a secondary meaning, "probably based on resemblance." So the slang was real, but the fruit came first.
The Nahuatl word lives on in a second English borrowing. It formed compounds such as ahuacamolli, avocado soup or sauce, which Spanish turned into guacamole.