Link already knew Epona's Song, so either Malon gave him Epona or he took Epona by playing Epona's Song and running away with her.
Majora's Mask is a direct sequal to the end of OoT. When Skull Kid steals Epona he possibly sells her to Romani Ranch, explaining why she ends up there later.
To the first answerer, Link was sent back by Zelda to a point before he had learned the song from Malon - explaining why he didn't know it until Romani taught him. To the second answerer, A Terminan Gossip Stone states that Epona was taken in by Romani and Cremia after she was sent to Termina by Skull Kid. I think that after Link came forth with news of Ganondorf's upcoming betrayal in OoT, he was hailed as a hero by the people of Hyrule. As appreciation, the people at the castle reforged his Kokiri Sword and gave him a Hero's Shield, Zelda herself gave him the Ocarina of Time, and Lon Lon Ranch gave him Epona, since in OoT she seemed to be the only horse there that was small enough for him to ride properly.