The Transformers have been at war, Autobot against Decepticon, for millions of years. However, not all of them have always remained on the same side throughout that time. Particularly when it comes to the Decepticons, many of them have been convinced of their need to change sides in the comics over the years.
Source:https://www.cbr.com/transformers-comics-first-decepticons-became-autobots/