The old way: Drill a vertical hole. When you want the drill to go off at an angle, set a wedge-shaped length of steel (a whipstock) at the bottom of the hole and lock it in place. Drill down again. The drill gets to the wedge. The wedge is thin at the top and thick at the bottom so the drill is forced to one side. Drill further. Do the same thing again, forcing the drill over a bit more. Do it again further down the hole until eventually the drill string (the rods or pipes) are drilling sideways along a particular bed of rock. Sounds simple? Just imagine them doing all this down a hole around 20cm diameter and 2000m deep – and getting everything set in the right direction.
The new way: Steer the actual drill bit in the direction you want it to go. Rather than rotate the whole length of drill pipe from the rig at the surface, use a mud motor (powered by the pressure of drilling mud that is used to flush out the drill cuttings and to support the drillhole) to turn the drill bit. It can be fixed at an angle so it goes the way you want it to go, see picture on the left. It’s self-explanatory. Almost.
There are other methods, but I’ve probably said enough. I’m imagining eyes glazing over….
More basic stuff on oil and gas well drilling here