average velocity is = net displacement / total time
displacement is a vector quantity, if its positive in one direction , it will be negative in the other. Displacement is the distance between initial and final position irrespective of path taken. Hence if the body moves in one direction and then moves back in the opposite direction, we will subtract.
Whereas, distance is scalar and always positive. So we add up the total distance travelled while travelling the path. Hence we add up the total distance.