What was not what happened
Since you are specifying that it is a mechanical issue, I understand that it is not:
- a software error/bug.
- a sabotage.
- an accident caused from someone screwing up the things.
- someone who wrote the wrong number on some file and nobody noticed.
At least, it is not any of those in isolation. Those might happen only if there was indeed a mechanical issue.
Further, I think that a small calculation error that accumulates over time is not a reason for that. They surely would have computers evaluating the route continuously and they would alarm when they notice the slightest mismatch, and it would be soon enough for the correcting maneuvering to be very slim and done with no problem. And no doubt, the ship would have enough extra fuel to be used in the case of something going bad. By the way, New Horizons did a lot of correcting maneuvers in order to be able to visit Pluto and Arrokoth, so no doubt that a much more advanced civilization with a manned ship would also do.
The odds of crashlanding and why
Let's say that the ship was coming from A, targeting C and nearby the star B which hosts the planet D.
As other answers notes, since space is very empty and distances very long, the odds of randomly crashlanding somewhere are absurdly slim, so it must have a reason to pass near that planet, so it was not very random at all. A gravity assist from B is (as many other answer notes) a good candidate for being a place where the ship deviates. Otherwise, it would have no reason to go to "the wrong star" and much less "to the wrong planet". So something goes wrong when the ship passes near B and it crashlands on planet D.
Also, even if/when the ship happens to crashland on D, it is surely not a random event. Even if B happens to be a small red-dwarf star with several planets in close orbits (like TRAPPIST-1), space is still huge and mainly void.
There are many things that might go wrong in a gravity assist without destroying the ship nor sending it to be lost in deep outer space. My best candidate is this:
The ship is struck by a micrometeorite near B, and it damaged some important part of it, making it impossible to finish the journey to C.
So, they are in one of those situations:
- (a) the ship is in the eminence of being destroyed and must be repaired ASAP. They did some provisional duct-tape and glue repair, but it won't last long enough.
- (b) the ship is in a wildly off-course uncorrectable trajectory, so they must either land somewhere nearby or get lost in deep space forever without anywhere to land.
- (c) the cryosleep system or some other crew-survival system is damaged and nobody would be alive when the ship reaches B.
So the crew must do some emergency maneuver. Concluding that it is impossible for them to reach B without fixing the ship and that the ship can't be fixed without landing, they decide to land into the nearby planet D.
But, a soft landing is impossible because the micrometeorite damaged the part needed for proper landing. However, they can still maneuver the ship into a crashlanding (as long as it doesn't destroy the ship), but that would surely add further damage to the ship.
After landing, hopefully with all or at least part of the crew still alive, they can fix the ship, wait for a rescue or make that planet their new home.