After the Nine Tails attack, Obito was busy controlling the 4th Mizukage and Kirigakure. The Akatsuki was formed by Yahiko, Nagato and Konan. Obito (known as Madara at this point) came a bit later and he managed to manipulate Nagato.
Obito managed to convince Nagato and Konan that he was Madara, the one who gave Nagato the rinnegan. So Obito became a leader behind the scenes
He became Tobi when the Akatsuki decided to make their move (Kazakage arc) plus there was the fact that Orochimaru had left the Akatsuki and they needed another member.