During Avengers: Infinity War, Thanos stops at his home planet Titan, before going to Wakanda. Why did he need to go there? Why not go to Wakanda, where the fight was happening?
Thanos went to Titan because he had a rendezvous with the Black Order to collect the Infinity Stones from them.
Thanos: There are two more Stones on Earth. Find them, my children, and bring them to me on Titan.
Avengers: Infinity War
It's only when he gets to Titan and Strange is there and not Cull that he realises he must go collect those two Stones himself.
Stephen Strange: Oh, yeah, you're much more of a "Thanos."
Thanos: I take it the Maw is dead. This day extracts a heavy toll. Still, he accomplished his mission.
Avengers: Infinity War
Why Titan, as opposed to anywhere else? Because of its emotional significance to Thanos.
Adding to the answer above, we find Thanos in an especially reflective mood on Titan, taking time out to reminisce about his childhood and the state of his planet, how he could have saved it if only he'd been able to decimate the population.
... he focused on Thanos, who was lost in the past that once more walked about him like a ghost. "Titan was like most planets. Too many mouths, not enough to go around." He sounded frustrated. "And when we faced extinction, I offered a solution " "Genocide." Strange did not mince words. "But random," Thanos agreed, to Strange's shock. "Dispassionate. Fair to rich and poor alike. They called me a madman. And what I predicted came to pass." Thanos unflexed the Gauntlet and reality returned to Titan.
Thanos' goal was to collect all of the stones into one place. Although he had the choice to meet with his minions literally anywhere in the galaxy, Titan seems the obvious choice to Thanos because that's where his quest for the stones initially began, even if he was unaware of it/them at the time. Returning to his home world brings his personal story full circle.
This is largely inference, but Thanos' original plan appears to be for Maw and Cull to get the Time stone, Proxima and Glaive to get the Mind stone, and to personally get the Reality and Soul stones. Thanos' belief that his Black Order would be able to get the stones was based around surprise: Proxima and Glaive probably intended their surprise attack to kill Vision before he was aware of the danger. Given the ensuing battle, it is reasonable to believe that if Vision had been killed immediately and no further Avengers had shown up, Proxima and Glaive would have prevailed (Scarlett Witch would have had to not only hold them off, but cart Vision's corpse around with her the whole time; if she left it unguarded, they could just snatch the stone and leave).
The Battle of Wakanda was the Black Order improvising after the previous plan to get the Mind stone failed. It wasn't part of Thanos' original plan, and once it began, Thanos was already expecting Maw on Titan, and would want to meet him there. He didn't know until he got to Titan that Maw was dead, so as far as he knew, Maw didn't know about the impending attack on Wakanda, and so wouldn't know to go there, even if Thanos had wanted him to.
Meanwhile, Thanos' plan probably didn't account for Heimdall using the Bifrost to send The Hulk/Banner to Strange and warn him about the impending attack. Had they not had that warning, and Stark and Parker not gotten to the Q-Ship, Strange would have arrived on Titan alone and immobilized, and far from any reinforcements.
At that point, Thanos would have had to get the Time stone from Strange somehow. It's unclear that he was aware of how well Strange would be able to protect it, but basic prudence would suggest having the encounter between Thanos and Strange not be on Earth, as once the element of surprise was lost, Earth forces may have been able to interfere. If everything had gone according to plan, Strange would have been alone and immobilized, while Thanos would have four Black Order members and all but one of the Infinity Stones.
In addition, Knowhere, Vormir, and Titan are likely in the same galaxy (the Kree galaxy). Thanos didn't know the location of the Soul stone before capturing Gamora, but he seemed to know that Gamora knew, and if Gamora had only looked in the Kree galaxy, then Thanos could conclude that that is where it was. Thanos knew that once he collected the Time and Mind stones, there would be a lot of people coming after him to stop him from assembling the Gauntlet. Getting the Soul stone involved luring Gamora to him, so that was probably the most variable part of his plan. He would want the rendezvous close to the Soul stone, so if his luring Gamora gambit took a long time, he would need as little time to travel to the stone's location.
But given that his entire quest started on Titan and was driven by regret at failing to save Titan, he likely simply wanted the completion of the quest to be on Titan. He seems to have a certain kind of sentimentality like that.