Answer: We don't really know. But we have lots of theories.
Let's start with what exactly domestication is. Wild animals can either be tamed or domesticated. A tame animal is an individual who has gotten used to humans. A domesticated animal is part of a species whose involvement with humans has resulted in extensive behavioral and biological changes.
We do know that dogs were once wolves, and we know that they are domesticated because of the many profound changes they've undergone. Physically, most dogs look quite dissimilar to wolves. Their ears can be floppy, their faces are shorter, their tails may be curled over their backs, their coats have far more color patterns. In short, they physically look more like wolf puppies than adult wolves.
This tendency towards puppy-ness is called paedomorphism, and it also describes wolf vs. dog behavior. Wolves are more physically active, mouthier, more destructive, have far more desire to roam, and are generally more wary of new experiences than are dogs.
As for when domestication happened, well, according to fossil evidence, domestication happened 12,000 to 14,000 years ago. According to DNA analysis, it happened around 80,000 to 130,000 years ago. So who knows!
There are three main hypotheses about how wolves became dogs:
The Village Dog Hypothesis suggests that wolves hung around human settlements, scrounging for food. The boldest, friendliest wolves were more likely to live (as the ones who threatened villagers were likely killed), and they slowly evolved into dogs.
In the Hunting Hypothesis, wolves and humans developed a symbiotic relationship. Either wolves began following the humans or the humans began following the wolves while hunting. They tolerated one another because each could offer the other an advantage in hunting. Again, the wolves that worked cooperatively with humans would have a better chance of breeding.
Finally, we have the Nurturing Hypothesis, in which wolf pups whose mothers were killed would be brought back to the village to be raised, likely by children or women. The more docile pups would live to adulthood to pass on their genes.
So there is your down-and-dirty overview on how dogs (maybe) became dogs.