Why did Madara pose as Tobi when with Deidara?
First of all


  Tobi is not Madara. He claims to be Madara, and everybody believes it, that's all. 


Tobi's true identity is:


   Obito Uchiha. He pretends to be Madara because he does not want to reveal his true identity because he should already be dead.


He keeps his goofball attitude so 


   that he can pretend to be someone else (Tobi),  but once everyone calls him Madara, he changes his attitude to serious.