The domestication of the dog pre-dates civilisation, possibly by 10s of thousands of years. The earliest date of domestication we have evidence for is about 33,000 years ago - this is the Razboinichya Cave dog (AKA the Altai dog) from c. 33,000BP which is described as showing signs of domestication.
The dog: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3145761/
Its genetics: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3590291/
The latest possible date is about 14,000 years ago. This is the Bonn-Oberkassel dog, a domestic dog found buried together with two humans. This dog was originally identified as a wolf, but detailed analysis of its morphology says "dog":
More recent genetic testing supports the Bonn-Oberkassel dog being a domestic dog. The genetics of modern domestic dogs and wolves doesn't give a reliable time for their genetic divergence - our best estimate is about 20,000 to 40,000 years ago. However, even the relatively recent Bonn-Oberkassel dog pre-dates civilisation and farming, and the domestication of other animals, by thousands of years.
As far as we can tell from the genetics of modern dogs, they were domesticated once, and the domestic dog then spread around the world. Genetically, there are three main groups of domestic dogs: East Asian, American, and Eurasian. Both American and Eurasian dogs appear to be derived from East Asian dogs, with American dogs being genetically isolated from other dogs from very early until post-Columbian times. Eurasian dogs were not isolated from East Asian dogs. While the dingo is sometimes classified as a wolf or a subspecies of wolf, it is most probably a domestic dog of the East Asian lineage, and is closely related to SE Asian and New Guinean domestic dogs.
This "domesticated once and then spread" pattern is common, among both domestic animals and plants. There are cases of independent domestication (e.g., cattle being domesticated independently in Western Asia and South Asia and possibly also Africa, pigs being domesticated independently in West Asia and China (European pigs genetically a lot differ from West Asia pigs, but this is probably due to interbreeding of domestic pigs of the West Asian lineage with European wild pigs), water buffaloes in South Asia and SE Asia), but single-domestication-and-spread is more common.
The domestic cat also shows this single-domestication pattern. There may have early domestication of other cat species, such as possibly the serval in Egypt and probably the leopard cat (Prionailurus bengalensis) in China, but both were replaced by the domestic cat.
Cats and dogs appear to have both spread primarily as "useful" animals rather than as companion animals (pets). Cats performed valuable service as rodent killers, and dogs were used for hunting, as guard animals, as pack animals, and as food. It's quite possible that the transition to companion animals (sometimes retaining a minor role as rodent killers and guards) happened independently in many cultures.
For more on the domestication and taming of various cat species, see my answer in https://www.reddit.com/r/AskHistorians/comments/rswapa/domesticating_larger_cats/
For more on dogs, see my answer in https://www.reddit.com/r/AskHistorians/comments/hifuym/were_the_dogs_of_the_americas_domesticated/ and also
Kylie M Cairns, "What is a dingo – origins, hybridisation and identity", Australian Zoologist 41(3): 322–337 (2021). https://doi.org/10.7882/AZ.2021.004
Anders Bergström et al., "Origins and genetic legacy of prehistoric dogs", Science 370, 557-564 (2020). https://doi.org/10.1126/science.aba9572