wow you guys are really looking into it too much. There have been many instances where a bunshin was created at the very last second and just swapped/kawarami/whateva

also, madara was not "defeated by a clone" nor is "wood bunshin be as effective as a kage bunshin"
notice how the clone is on the ground and madara is standing?
(then again, of course a wood bunshin is more effective than a kage bunshin like Madara even said himself)

hell he doesn't even have his sharingan activated (error or not) if you really need an explanation

I highly doubt that Madara cast a genjutsu or made a clone, since he stated numerous times how he was defeated and left for dead in this battle, and up until getting shanked in the back, I would hardly say he was defeated.