How do aircraft go off-course even with all their guidance technology?
1) Technology is fallible.

2) Humans are fallible.

Now that aircraft have GPS receivers it is rare for them to be off course by a considerable margin. That said, technology can fail and there are cases where the GPS cannot, or should not, be used.

The crew can also make mistakes, either by incorrectly reading the navigation data or by incorrectly entering flight path details into the navigation system: An aircraft may actually be 'on course' based on what the crew told it to do, but they told it the wrong thing. Depending on how data is entered into the system it's easy to add the wrong waypoint (some have very similar names, there's been a few cases of that happening) or to enter reciprocal bearings or lat/lon points.
On top of that there's simple crew distraction - if they're manually flying then they may be focussing on something else and not notice that are off-course: As happened on the Sukhoi superjet demonstration flight a few years ago.