A race called the Quintessons resurrect Prime as part of a plot to steal the Matrix of Leadership. Hot Rod willingly gives it back to Prime, not knowing that he's under the control of others. Once Prime has it, he turns on the rest of the Autobots. This could be where we see him attacking Bumblebee. Prime is able to eventually overcome the control, so we know the real him is still somewhat conscious, which could explain Prime apologizing to Bumblebee during the attack.
Optimus Prime
Bumblebee