It is considered the length of a horse from head to tail, so if a horse wins by 3 lengths it is effectively 3 horses in front in terms of distance.