1)
How did Gad know to tell this to David?
1.
Malbim: It says in Divrei ha'Yamim I, 21:18 that the angel told Gad; prophecy comes via an angel. Also the miracle of fire descending [from Shamayim] to the Mizbe'ach (ibid., 26) was via the angel. The destroyer himself prepared the cure for them - "Machatzti va'Ani Erpa" (Devarim 32:39), "Yimchatz v'Yadav Tirpenah" (Iyov 5:18).
2)
Why did he say "Aleh"?
1.
Radak: Aravnah's granary, the place of the Beis ha'Mikdash, is higher than Yerushalayim.