Spoiler alert for if you haven't finished the manga or anime
Madara used the Izanagi to cheat death (just like I said in the comment section). The second part that I said was wrong. When he was fighting Hashirama he bit off a part of his (Hashirama's) arm, then after his "death" he vomited up the piece of flesh and implanted it into his wounds, which let him activate the Rinnegan (in both eyes).
You should remember that Hashirama is Ashura's reincarnation and Madara is Indra's (Ashura and Indra are The Sage of Six Paths' children), which is the reason why he was able to awaken it (Rinnegan) in the first place.
The Rinnegan can typically be awakened by gaining Hagoromo's chakra either by reproducing it from combining the chakra of Hagoromo's sons, Indra and Asura, or by directly receiving chakra from Hagoromo himself.
Also,
Madara's Sharingan did not become Rinnegan until decades later, at the end of his natural lifespan; this also seemingly restored the eyesight lost from his use of Izanagi.
So he didn't awaken the it right away. (The other part of your question is also answered above).
Sources:
- Naruto volume 71: I love You guys
- Rinnegan