It is 100% because of the Greeks. They and the Romans called coastal Cushitic people like Bejas, Afars, Sahos and Somalis, or at least whatever our ancestors went by, "Barbaroi". Even the Aksumite rulers who had a hard-on for Greek at certain points adopted this. The Tuaregs' haplogroup similarity to Somalis isn't, as far as I know, any greater than the similarity between us and other Berbers. We are all mostly descended from E-M35 (mostly
M78,
M81 etc) Paleolithic North-Africans in terms of Y-DNA in the Horn and Maghreb.
As for the similarity in looks
sometimes, it stems from the fact that Tuaregs are a MENA+SSA mixed people like us except they lean more MENA than we do on average. But their MENA element is different from ours.
Ours is more like pre metal-age Egyptians with a bit of roughly iron-age South Arabian whereas theirs is more like modern Berbers and their SSA is mostly West-African (think Gambians or Yoruba) whereas ours is more like the Dinka or the Gumuz.