They were the first animal to be domesticated, by a wide margin. With dogs domesticated approximately 30,000 years ago, when the neolithic revolution rolled around about 12,000 years ago, and other plants and animals started being domesticated, dogs were already firmly established as human's partners. Even then, most animals being domesticated were for consumption, and we didn't tame a non-food animal until the cat about 8,000 years ago.
The domestication of the cat also happened in a much different way. Humans and dogs started working together while we were still hunter gatherers and we hunted in similar ways. Cats were tolerated hanging around settlements because they ate pests like rats and mice, while cats tolerated us hanging around them because their food was near us. We never entered the same sort of direct cooperation with cats the same way we did with dogs.
If you are curious as to why dogs were domesticated so early, it has to do with hunting techniques. Humans and wolves are both animals with exceptionally high endurance, which means that not many other animals would be able to keep up with either one of us. It is uncertain if the first encounters were us following them for scraps of food from their kill or the other way around (I personally think it was likely a bit of both), but we eventually built a symbiotic relationship as we worked together to catch our prey. No other animal would have been able to keep up with our persistence hunting style or been as mobile and roaming as we were.
hi! there's a section on dogs (and cats) as pets in the FAQ* - check it out for previous responses
*see the link on the sidebar or the wiki tab