How and when did Uchiha Madara learn Edo Tensei?
It is not really stated how and when Madara learned to use ET.

But it is possible that during the battles between Senju and Uchiha, Madara had seen Tobirama use it. And since ET is not a bloodline jutsu, and Madara as top Uchiha ninja, he copied it with Sharingan's ability.