However, very few people go to a barber for a shave anymore. It used to be that most people would go to a barber for a shave, and shaving yourself was unusual. Since the advent of the safety razor, cartridge razor, and electric razor, it's the other way around, where it is unusual to go to a barber for a shave. But in many states, training on shaving is a large part of the training for barbers.
In fact, it also used to be the case that barbers were the surgeons as well, though I don't know how much of that time overlapped with the licensing era.
I don't know how much of the remaining licensing process for modern barbers has to do with actual safety concerns, or is just inherited from the times of barbers being surgeons or doing the majority of shaving with straight razors.