The Wikipedia treatment of the topic, Names of the Greeks, is pretty damn good.
The Classical Greek term for Greeks, Hellenes, had not generalised until early Classical times. Before then, Greek tribes used local terms for themselves, and any peoples that came in touch with them would pick up those local terms, rather than Hellenes. Hence:
* Homer predates the generalisation of Hellenes, and his word for Greeks (who he contrasts with the non-Greek Trojans) is Achaeans. In Homer, the Hellenes themselves are only one Greek tribe; in later usage, so were the Achaeans. It is likely that the Hittites used a variant of Achaeans, Ahhiyawa, to refer to Greeks.
* The Persians were first in contact with the Ionian Greeks, so they called Greeks Yunan. Peoples of the Middle East who learned of the Greeks via the Persians, or whose cultural heritage came from those who did, stuck with that term.
* The peoples of Italy came to refer to Greeks as Graeci, possibly from the name of a tribe in Western Greece that they first contacted. Peoples who learned of the Greeks via the Etruscans (e.g. the Romans), or whose cultural heritage came from those who did, stuck with that term.
* The Greeks themselves came to abandon the term Hellenes, which came to mean “pagan”, and used Rhomaioi “Romans” instead, because they belonged to the East Roman empire. The term Hellenes was revived in wide use in the 19th century.
* And so Wikipedia informs me, the Georgians call Greece Saberdzneti, from the Georgian word for wisdom.