Here's what happens:
* Initially, Starscream is still a Decepticon, plotting against Megatron and seeking to usurp his leadership.
* During the battle of Chicago, Starscream gets caught in the crossfire and becomes a casualty. He's captured by NEST (the human military organization) and *briefly* offers to assist them in defeating Megatron.
* He still ultimately prioritizes his own survival, however, and his allegiance to the Autobots is short-lived. He later escapes and rejoins the Decepticons.
So, Starscream's turn isn't a genuine change of heart, but rather a strategic maneuver designed to improve his own position. He doesn't truly embrace the Autobots' cause, and his motives remain self-serving.