hagoromo said that the reason why he was able to emerge was because madara's lower half contained hashirama,madara and the tentails but then he said rather it contains ninetails,indra and ashura
with hashirama and madara it was pretty straight-forward
madara got hashi's chakra through his dna...