Don doesn't like someone telling him what to do. After being put on leave for telling embarrassing details to a client, he comes back to SC&P, loses his privileges and has to work for Peggy. At first, he rebels but Freddy convinces him to play ball and work his way back. Which he does. That must be a big lesson for him.
When he arrives at McCann Erickson, he's again in an environment he doesn't like: too bureaucratic, too rigid with procedures. So he rebels again, or it's actually more like another breakdown because of other factors.
It's safe to say he's pretty lost in the last episode, after Stephanie's disappearance and his phone call to Peggy. What does he want to do? Nobody seems to want him anymore. Then comes Leonard, the fridge man, a poor guy that has never been noticed by anyone. His story triggers something in Don, who seems to empathize.
I think he realizes at that moment that he loves being the centre of attention and being desired by other people. The next day, 'new day, new ideas, a new you', he finds an idea of ad for Coca-Cola and comes back working for MCE. After all, he saw that he could endure working in non-ideal conditions.