How were the languages learned by those who did not speak them natively?
This is only a partial answer, but there's evidence that at least some of the Pandyan Dynasty elites (in what is present day South India) were formally taught Greek, and had access to manuscripts written in both Greek and Latin. In the Western Satraps, which also contained some trade hubs, there was at least some penetration of Greek after ~200 B.C.E. (about 80 years before the establishment of early Indo-Roman trade) as the result of the Hellenistic invasions and the formation of the Greaco-Indian kingdom.
Finally, at least some Romans probably spoke some Tamil, as evidenced by locally-produced potsherds with Tamil script in Laodicea.
I'm afraid that for more specific answers about the language of trade, I'll have to defer to a subject-matter expert.
Initially at least, they would have traded in Greek. The Greeks had been trading directly with southwestern India since the late second century BC (c. ~118 BC) when Eudoxus of Cyzicus opened up the direct trade route with the aid of an Indian sailer, who was discovered shipwrecked in the Red Sea. Strabo's Geography has this fascinating passage about it (in which we also find out that the Indian first had to learn Greek):
Now it so happened, the story continues, that a certain Indian was brought to the king [Ptolemy VIII] by the coast-guards of the recess of the Arabian Gulf [Red Sea], who said that they had found him half-dead and alone on a stranded ship, but that they did not know who he was or where he came from, since they did not understand his language; and the king gave the Indian into the charge of men who would teach him Greek; and when the Indian had learned Greek, he related that on his voyage from India he by a strange mischance mistook his course and reached Egypt in safety, but only after having lost all his companions by starvation; and when his story was doubted, he promised to act as guide on the trip to India for the men who had been previously selected by the King; and of this party Eudoxus, also, became a member.
So Eudoxus sailed away with presents; and he returned with a cargo of perfumes and precious stones (some of which the rivers bring down with the sands, while others are fortified by digging, being solidified from a liquid state, just as our crystals are).
http://penelope.uchicago.edu/Thayer/E/Roman/Texts/Strabo/2C*.html#3.4
Later on, Rome would take over Ptolemiac Egypt and hence the trade with India.
However, I think it's important to note that trade between India and the Mediterraean world had been going on long before Eudoxus, going back all the way to the trade in gemstones between Egypt and the Harrapan civilization in the third millenium BC (see the lapis lazuli gemstone trade). Although in this case, the shipwrecked sailer had to learn Greek, it's very likely there were already merchants along the southwestern coast of India who could speak the language by this time.