An accident . . . . . but probably set up earlier by the humans if they were allowing their dog to playfully tug at their clothes as a matter of habit.
Dogs play with each other by grabbing the scruffs of their necks and throwing each other around. As puppies, they think you're a dog as well and want to play with you the same way. You have to show them you're different or the cute puppy becomes a big dog still doing what it thinks is normal.
Do not do this with humans!!!