The only way to defeat her is using the yin & yang seals hogaromo has and Madara doesnt have it.
Yeah he does.
Madara has the apex body.
Naruto and Sasuke got half of what madara has each.
He is the true second coming of the sage.
Kaguya is overall more powerful but,she lacks his finesse and was alive before the dawn of shinobi so she has no combat experience with ninjustu which is why she only used her powers to manipulate the earth and space time abilities.
She was only using straight up yin-yang techniques.
Madara on the other hand just obtained his second and third eye right before he was taken over.
That madara was already easily over powering both naruto and sasuke and was about to finish them for good when he was over taken.
Also it went on record by kishi himself that madara was invincible and the strongest character in the series.