According to Star Wars wiki, the two planets are in different star systems. How did Queen Amidala and the two Jedi get to Tatooine with a broken hyperdrive? Wouldn't that take thousands of years at normal speeds?
The hyperdrive wasn't broken, it was damaged. It had sufficient (insert technobabble here) to get them to a nearby system.
This is explained in the film's script
RIC OLIE : There's not enough power to get us to Coruscant...the hyperdrive is leaking.
QUI-GON : We'll have to land somewhere to refuel and repair the ship.
and in more detail in the novelisation
When they were well away from any Trade Federation presence, Ric Olié made a thorough check of the controls, assessing their damage, trying to determine what was needed. Obi-Wan sat next to him in the copilot’s seat, lending help. Qui-Gon and Captain Panaka stood behind them, awaiting their report. The Queen and the rest of the Naboo had been secured in other chambers. Ric Olié shook his head doubtfully. “We can’t go far. The hyperdrive is leaking.”
Qui-Gon Jinn nodded. “We’ll have to land somewhere to make repairs to the ship. What’s out there?”
Ric Olié punched in a star chart, and they hunched over the monitor, studying it.
“Here, Master,” Obi-Wan said, his sharp eyes picking out the only choice that made any sense. “Tatooine. It’s small, poor, and out of the way. It attracts little attention. The Trade Federation has no presence there.”
The hyperdrive generator had failed completely as they landed. It’s a good thing it didn’t give out between star systems, Qui-Gon thought, looking down at the mess Obi-Wan had just hauled out of the drive compartment. Perhaps that was what had made him so uneasy, these last few hours … but no, he could still feel disquiet in the Force.
Should I point out that the Star Wars universe has to have different physics. I mean the Millennium Falcon could get to Bespin from the system containing Hoth without a hyperdrive. If there is no FTL barrier in the Star Wars universe, (or there are other means to travel faster than light than using a hyperdrive) they can get to the Tatooine from Naboo with regular drives.