This is pure speculation. I've not done any research on the domestication of dogs from wolves. My knowledge on the subject is limited to the basics: dogs came from wolves, who were first domesticated by Man thousands of years ago.
I'm starting this post based on a meme. The meme shows a picture of a majestic wolf a snow-covered forest. He is pondering a campfire he sees in the distance, and asks himself, "Maybe they'll give me food over there at that campfire...what's the worst that can happen?" The next image in the meme is captioned "10,000 Years Later" and shows a puny, emaciated Chihuahua with a goofy, clueless gaze, dressed by his owners in a ridiculous knit birthday cake hat for an Instagram post.
The meme is hilarious, yes, but it is also optimistic. In the meme's history of Dogs, they are simply Wolves who chose to befriend Man of their volition. I can imagine a timid timberwolf approaching a campsite with his head down, tail between his legs, and eyes glowing with cuteness. Turning him down and denying him food would be like telling Oliver Twist to get lost.
Honestly, that's how I hope things happened. Because I got to thinking about the problem of domesticating wolves, and it's not too pretty.
My theory of how wolves were domesticated and bred into dogs starts with the behavior of wolves. Wolves are dangerous creatures. They are very strong compared to humans, and they are basically in the same weight class as fully grown adults. They run faster than humans, they can smell better than humans, they can see in the dark, the list goes on. But to make everything worse for humans, they form packs and work together when hunting.
Humans also form packs and work together when hunting. This would have made humans and wolves natural competitors in the early times. I believe that the domestication of wolves starts here, with the danger that wolves posed to humans.
I think it's possible that our ancestors recognized the danger wolves posed to them. The wolves probably killed a number of men in those days. But men are smart, so we learn from our fights. It was probably observed that killing the largest, most fierce wolf in a small pack tended to drive the others away. It's worth it to note that wild wolf packs are usually families, so I'm not drawing on the typical Alpha and Beta wolf theory in making this observation, but the fact that when the strongest member of a family dies in the middle of a hunt, the hunt is probably off. So I think the humans would start targeting the leaders in self defence against wolf attacks. It's either that or that the smaller wolves followed the larger wolves wherever they went.
The key here is that it was observed that wolves can work in groups and that they are capable of following another wolf, the leader.
The second part of my theory is where it turns dark. I expect humans to have realized that they weren't much of a match against wolves in fights. But they definitely would have realized that wolves often fight each other. An unarmed man can't do much against a wolf one on one, but a wolf can certainly hold its own against another wolf. Second, it was probably also observed that wolves tended to avoid rival wolf territory. One wolf would be a friend to a wolf of his group, but an enemy to any other wolf on sight. In fact, wolves probably avoided entire areas altogether if there were rival wolves nearby.
Observing this, I suspect humans decided to turn wolves into tools for their own protection. However, one can't just grab any wolf in the wild and make it one's friend. The only way to safely attempt to befriend a wolf is when it is small...a puppy. So, I suspect that humans deliberately tracked pregnant wolves and killed the mother after the pups were weened, stealing the litter and raising them as their own. This would have been difficult, sure, as "mama bear" certainly also applies to "mama wolves". But an entire group of people dedicated to one task can certainly achieve it. Think about the Mammoth hunts.
So, the theory I have about the origin of the domestication of wolves involves people stealing them from their dead mothers and raising them as their own, all for the purpose of using them for protection.
At first, they probably didn't bother with domesticating them. They probably kept them caged up and fed them scraps to keep them going. It was just that having a couple of wolves in the campground meant that wild wolves would be less likely to attack, thinking the area to be controled by a different group of wolves already.
Later, I imagine that after keeping some wolves locked up like this, they noticed that the wolves became attached to the one who fed them. Raised from pups, they would probably have some kind of loyalty to this person, but it still would not have been safe to let them out. Over time, the wolves had pups, and those pups had pups, and so on. All raised in captivity. Soon, a type of "dog" was born - one that was hardly any different than a wolf. It would have been extremely violent and dangerous to let around small children, but it would have been useful on hunts and for protection.
Slowly but surely this would have continued, with each generation of dog becoming slowly more domesticated and less violent, until one day, 10,000 years later, I would be putting a Christmas sweater and knit cap on my tiny, shaking Chihuahua-Dachshund mix.
Bonus: it's also possible that the capturing and domestication of wolves is what led to the practice of farming livestock.