It's best to look at this story problem starting with the result: Both trips combined took a TIME of 3 hours. As you know, speed is expressed in terms of distance divided by time (the average speed is the total distance traveled divided by the total time):
speed = distance / time
Such as 4 miles / hour. Therefore, as shown in the solution above, the time it took her to go UP the mountain PLUS the time it took her to go DOWN the mountain must equal 3 hours, but we don't know the distance... that's what the problem asks us to find.
However, we do know it's the same up as it is down (that's how mountains are laid out, generally). And we also know the average speed for each direction, 4 and 20 mph. Solving the equation above for time, we have
t = d / s
And then, the arithmetic follows easily. (time up) + (time down) = 3 ... d/4 + d/20 = 3 ... 5d/20 + d/20 = 3 ... 6d/20 = 3 ... 6d = 60 ... d = 10 miles.