In some fanfictions, it could be through a strange and powerful jutsu transfer. Maybe Madara, on the verge of defeat, decides to transfer his Rinnegan power to Naruto for some unforeseen reason, like seeing a new path for the ninja world in Naruto.
Naruto would probably win. He has an indomitable will and has always found ways to overcome powerful foes. His experience and the unique powers he might gain with the Rinnegan could give him an edge over Madara.
One possibility is that there was some sort of spiritual or chakra - based connection between Naruto and Nagato. Nagato, being the possessor of the Rinnegan, recognized Naruto's strong will and the fact that he was on a path to change the ninja world for the better. Through this connection, Nagato was able to transfer the power of the Rinnegan to Naruto. It could also be related to the nature of the Sage of Six Paths' power that was somehow involved in this transfer, as both Naruto and Nagato were related to the Sage in different ways.
A good Naruto Rinnegan Madara fanfic should first of all stay true to the character. Madara is a powerful and complex character, and his Rinnegan abilities should be portrayed accurately. For example, his ability to control the tailed beasts using the Rinnegan should be shown in a way that makes sense within the Naruto universe.
I remember a fanfic that focuses on Madara's past and how he obtained the Rinnegan. It's really detailed and gives a whole new backstory to his character. It also shows how his Rinnegan powers evolved over time. This fanfic has great character development for Madara and also includes some interesting side characters that interact with him in different ways related to his Rinnegan abilities.
Power. Most fanfictions focus on the extreme power of Madara's Rinnegan. They explore how it can be used to dominate battles or change the Naruto world. Another common theme is mystery. Since the Rinnegan has many unexplored aspects in the original series, fanfictions often try to uncover its secrets.
One possibility is through some sort of transplant or transfer. Maybe Madara, before his death, found a way to transfer his Rinnegan to Naruto. It could be a last - ditch effort to pass on his power to someone he saw potential in. Another way could be through some sort of ancient jutsu or curse that links their fates and causes the transfer of the Rinnegan.
Another possibility is that it's a result of some strange chakra experiment gone wrong (or right). Scientists in the Naruto universe are always dabbling in chakra research. Maybe an experiment meant to enhance her natural abilities instead gives her the Rinnegan, and she then has to learn to control it quickly to avoid being consumed by its power.
One common theme is power exploration. Writers often delve into how Madara's Rinnegan powers could be used in different scenarios, like battles against other powerful foes. Another theme is redemption. Some fanfictions might explore if Madara could be redeemed with his newfound power. And of course, there are also stories about his past and how he obtained the Rinnegan in the first place.