I believe that he had hashirama's DNA before going to attack the village and fighting hashirama for the last time. When hashirama left the battlefield, the zetsu clone came to transport them and connected madara to the mazou until obito went there. That is how i think madara survived. He...