The ancient Greeks and Romans had no concept of historical linguistics or of the Indo-European language family. However, it would have been noticeable to anyone who spoke even a little of both Greek and Latin that they shared many similarities, most obviously in basic vocabulary such as kinship terms and numerals, but also in some of the inflectional endings. Further afield, there would have been some scholars or travelers who had knowledge of other IE languages, such as Persian, or even of Indic or Germanic languages, and who could easily have noticed the same similarities (while, on the other hand, someone familiar with a non-IE language -- Semitic, Etruscan -- could have seen that these shared features were absent there). What did they think the reason for this was? Do we have any surviving writings that address the question of why these languages have so much in common?
My guess would be that anyone thinking about this question in those times would have done so in a 'genealogy of peoples' framework, where e.g. the Romans were descended from the Trojans, etc., and tried to explain the linguistic facts that way. But do we actually know?