If they switched sides in fanfiction, it would be a huge shock. Optimus as a 'bad guy' would be very different. He might use his leadership skills in a more tyrannical way. Megatron as a 'good guy' would be strange too. He'd have to fight his own nature of seeking power. But it could make for an interesting story as they both struggle with their new identities.
In a fanfiction where they switch sides, the whole dynamic of the Transformers universe would change. Optimus Prime, now on the side of the Decepticons, might start to question the violent methods he once opposed. He could try to bring a more peaceful approach to the Decepticons, which would likely cause internal conflict. Megatron, now with the Autobots, would have to learn to work within a team structure that values cooperation rather than his usual solo domination. This could lead to some really interesting character development and new storylines.
One possible fanfiction could be about Optimus Prime and Megatron having to team up against a greater threat. Maybe an ancient evil from Cybertron's past resurfaces that is so powerful that their usual enmity has to be put aside. They start off distrusting each other but as they face battles together, they gradually come to respect the other's fighting skills.
In a fanfiction where they unite, it could start with a common threat that neither side can face alone. For example, an alien race invades Cybertron. Megatron and Optimus Prime realize that their brotherly bond is stronger than their differences. Together, they could form a new strategy, using both Autobot and Decepticon forces in a coordinated way to repel the invaders.
Fanfiction about them can explore different universes and scenarios. For example, what if they were raised together? How would their relationship be different? It gives fans a chance to play with the established lore and create new and exciting stories that the official Transformers storylines may not explore. It also allows for deeper exploration of their motives and personalities.
A fanfiction could also explore a post - apocalyptic Cybertron where Megatron and Optimus Prime are the last two Transformers alive. They have to put aside their differences to try and rebuild their world. This would be a very emotional and character - driven story. They would have to confront their past actions and the reasons for their long - standing feud. As they work together, they might discover that they are not so different after all, and that their shared love for Cybertron could be the key to its restoration.
In a fanfiction, it could be interesting to see a scenario where Megatron and Optimus Prime are reborn in a different time and place, perhaps in a peaceful Cybertron that has long forgotten the war. They might struggle to adapt to this new world where their old identities as war leaders are no longer relevant. Their journey could involve rediscovering themselves and learning to live in harmony, which would be a huge departure from their traditional roles.
One possible fanfiction could be that they are brothers separated at birth. Megatron is raised in a harsher part of Cybertron, which shapes his more aggressive views, while Optimus Prime is raised in a more diplomatic environment. Their reunion could be a turning point for the entire Cybertronian civilization.
You can try looking on some fanfiction websites like Archive of Our Own (AO3). It has a large collection of Transformers fanfictions, and there might be some related to Optimus Prime and Megatron in the MPreg genre.
It can also be appealing from a creative writing perspective. Writers can play with the personalities of the characters in this new and strange scenario. For example, how would Optimus Prime react to Megatron being in such a state? And vice versa. It gives a whole new layer to their complex relationship.
One interesting storyline could be a story where Megatron is injured in battle and Optimus Prime, against all odds, decides to take him in and nurse him back to health. During this time, they start to see each other in a different light and develop an unexpected bond.
Perhaps a fanfiction where a powerful artifact is discovered that has the potential to change the balance of power on Cybertron. Megatron wants it for his own gain, and Optimus Prime wants to protect it. But when they both touch it simultaneously, they are transported to an alternate dimension where they must work together to find a way back, all while learning more about each other than they ever thought possible.