She was sent by the remaining Avengers team on Earth, which includes Rocket at this point.
In the Captain Marvel post credit scene, she turned up in response to the beeper summons from Nick Fury before he dusted at the end of Infinity War.
She asks where Fury is, and is then presumably filled in on all that has happened.
As Rocket is on Earth, he would most likely know that Quill, Mantis and Drax had headed to Titan to try and save Gamora in response to Nebula's summons (in Infinity War).
He would have been able to tell Carol where to start looking for them, which gives a smaller search area for her to find them in.
It's also very likely that Nebula and Tony were broadcasting some sort of distress signal that could be picked up as soon as Carol got close enough.
The Avengers also refer to carrying out deep-space scans from Earth in Endgame, so they must have some sort of technology to allow them to try and pick up these signals -
perhaps Rocket helped them build something to help find Thanos.
scifi.stackexchange.com/users/65658/Dave
Since Carol Danvers apparently has the ability to detect Fury's beeper/beacon from across the galaxy (irrespective of light speed limitations, as shown in the mid- or post-credits scene in her own movie), I don't think it's all that far fetched that she can detect a distress beacon from Quill's ship after Stark and Nebula managed to get the power cells working well enough to get off Titan.
Both technologies are designed for FTL communication with similar information levels, and both are apparently within either Carol's powers to detect, or covered by Kree technology in her suit.
scifi.stackexchange.com/users/83999/Zeiss Ikon
Captain Marvel was "summoned" to Earth by Nick Fury at the end of Avengers: Infinity War when he activates the pager that she gave to him.
In the Captain Marvel post credits scene Carol arrives on Earth when the pager stops working and the Avengers still have their pre time jump looks.
I believe this scene takes place before Carol rescues Tony and Nebula.
If that is indeed the case we can assume the Avengers gave a rough idea to Carol about where to find Tony.
This is also plausible because we know the Avengers are tracking energy across the galaxy/universe as they find out where Thanos was hiding using the same technology in Avengers: Endgame .
Alternatively, Carol could have just run across them on her way back to Earth but this seems less likely as when she pops up to save them
she seems to be doing it on a purpose, as if she was told to find them and didn't just stumble across them.
scifi.stackexchange.com/users/58193/TheLethalCarrot
This is pure conjecture and not supported by any concrete evidence but my theory is that she followed a trail left by Maw's ship.
There's lots of people in the universe who would have known Thanos was from Titan but none of the Avengers or Rocket would have known for certain that that's where Maw was taking Strange.
However, Bruce was present in New York when Strange, Tony and Spiderman fought Maw and he saw them enter the ship
so he knew they were taken somewhere .
Assuming those ships leave a detectable trail and Captain Marvel has the means to detect that trail (both plausible assumptions
but I have no evidence to support either of them), she could have followed it and that would have eventually led her to Tony & company regardless of where they had gone.
And odds are, Tony and Nebula were headed back to Earth when they broke down so Carol would have run into them on her way to Titan, or at least come close enough to pick up their distress call.
scifi.stackexchange.com/users/42371/aleppke
It's likely that the post-credits "Where's Fury?" scene is canon .
I expect there was a much more elaborate "get to know you / debrief" scene that was intended to be part of Endgame , but it proved to be fairly dull and was cut for time.
Rocket absolutely knew "the morons" were going to
Titan I, and would have mentioned this to Danvers.
We know Danvers is pretty good at planetary surveying, so probably would've taken a pass around Titan.
She would have found the fresh disturbance of a fight scene, and the landing feet impresson of the Benatar (and no ship) and possibly a puddle underneath it.
Where did it go?
Where would it have gone?
From that it's a matter of either following whatever trail a ship may leave (especially a damaged ship leaking stuff).
Or simply guessing that they would make a beeline back to Earth, and following that path.
Or following a distress beacon - you have to figure if today's aircraft black boxes have a 30 day battery to power a sonar pinger, starship distress beacons have an independent power source too.
Also, Titan is hardly "not anything of significance", Thanos' homeworld matters.
Tony was joking about the nearby 7-11's; I'm sure the franchise in that part of the galaxy is Circle-K.
scifi.stackexchange.com/users/83623/Harper - Reinstate Monica
From the commentary included with Avengers:Endgame Captain Marvel was able to locate Tony and Nebula in space because the ship had a homing beacon.
She learned all that after the credits scene in Captain Marvel.
- BGR
Essentially, Rocket probably told her the ship had a homing beacon and gave her the frequency / info she needed to find it.
scifi.stackexchange.com/users/1148/Jack B Nimble
At the beginning of  Avengers: Endgame ,     Tony Stark is floating somewhere in space with Nebula.  Suddenly, Captain Marvel appears to rescue them.   But how did she know where to go?  Space is huge, they were nowhere near anything of significance, and they were out of contact with everyone.  How was she able to show up in the right place?
How did Captain Marvel know where to find these characters?
scifi.stackexchange.com
<marvel><marvel-cinematic-universe><avengers-endgame>
scifi.stackexchange.com/questions/211989
scifi.stackexchange.com/users/5490/Bobson
The official explanation is that Captain Marvel was abe to locate Tony Stark and Nebula because the ship had a homing beacon that she was informed about after the credits scene of the Captain Marvel movie. Other possible explanations include her having enough information from Nick Fury to make some rough assumptions or that The Avengers had the sort of technology necessary to carry out deep space scanning. There are a number of possiblities - e.g. perhaps the Avenger team on Earth sent Marvel after receieving a beeper summons from Nick Fury, perhaps Marvel detected the ship's distress beacon, perhaps Marvel followed the ship's train or perhaps she located them after seeing traces of the fight on Titan.
Captain Marvel was sent by the Avengers team on Earth, and after receiving a beeper summons from Nick Fury. Rocket would have known they were heading for Titan, thus narrowing the search area. As Carol Danvers can detect Fury's beeper from across the galaxy she would be able to detect the distress signal from Quill's ship. Perhaps the Avengers gave Carol a rough idea where to look - or maybe she just ran across them by chance. Maybe Carol followed a trail left by Maw's ship or she ran into them on her way to Titan. When she got to Titan she would have seen the signs of the fight and realised they were somewhere near there. Maybe Rocket told her the ship had a homing beacon and what its frequency was.