However, we can explain this fairly easily, as long as we assume that the intended course already took it on a path that passed close to, or directly on the way to, a star. That can be as simple as the intent being to use a star's gravitational pull to sling-shot them round on a new target without burning fuel to do so, and the downed engines throwing that off slightly, or just preventing them from escaping from the star's gravity well after the manoeuvre; the "collision course" is a slow spiral inwards.
An even better explanation is that they were originally on a more-or-less direct course with the star, with the show taking place as the ship nears its target, and that the issue is that, with the engine problems, they can't make intended final adjustments. With that in mind, there're any number of explanations here. Perhaps when it was launched, they didn't have enough data to target the exact planet that they were going for, so launched it for the sun with the intention that the ship would adjust course once it got close enough for it to be practical. Perhaps they did have a specific planet in mind but, in the time it's taken to get there, the planet was destroyed, moved, or otherwise no longer valid, and the ship's system didn't have a contingency for that, leaving it drifting close enough to the star to be pulled in. Perhaps they'd planned the most efficient time to get to the planet to save fuel, which would be when the planet was in orbit closest to them... or, to put it another way, by aiming directly at the star and timing it so they'd reach the planet first, but whatever happened to the ship threw off that timing.