They use the fact that the wind veers when going up, that is, changes direction clockwise, and backs, changes direction counterclockwise, when going down. This is largely (there are a lot of other factors but this is the one we are interested in) due to the tendency of air in the atmosphere to spiral away from high pressure toward low pressure (spiraling because of Coriolis effect; what makes draining water swirl - clockwise away from high pressure in the north, counterclockwise in the south).
Away from surface influence, the air spirals nearly perpendicular to the "slope" of the high pressure (think of it as a mound of air that wants to flow toward and fill in adjacent low spots but Coriolis effect makes it swirl as it does so). Closer to the surface, friction effects inhibit some of the Coriolis effect make air flow a bit more directly "downhill" toward the Low you might say, the more the lower you get.
For a high pressure area in the northern hemisphere where there is clockwise circulation as air flows away from the centre, this means the wind is more directly away from the center of the high at the surface than when higher up, where Coriolis effect is stronger and it "swirls" more. As a result the wind direction will change clockwise as you go up. And vise versa going down. In the southern hemisphere where the circulation patterns are reversed, it'll be the opposite; veering going down and backing going up.
This gives the balloonist some control over ground track by choosing a specific altitude that gives the desired track. Obviously, the amount of veering and backing being fairly small between the surface and 5000 ft, maybe 10-30 degrees, means the balloonist still has to pick a launch site that is upwind of destination. A launch site that is directly upwind based on the wind direction at, say, 2000 ft will give some left and right directional control by going higher to change track to the right, and lower to go left. The balloonist also has to account for wind backing during the descent to landing and allow for that in the "cruise" portion of the flight to get the best position for the final approach. Beyond that, it's control the altitude with the burner and hope for the best.