Humans have been using artificial selection to create new breeds of plants and animals for as long as we know, even if we have only very recently come to understand the science behind it.
Do we know what they understood about what they were doing? Did they have any explanations for why some characteristics were hereditary and others were not?
In my genetics class we went over a brief history of gene selection and its said that the Romans knew that breeding strong, healthy animals with each other would result in better livestock however they didn't know, nor care particularly why this happened. I would assume the same for other agricultural societies in that they knew that there was a benefit, but didn't have the info/resources to find out why
People have had an extremely incomplete, basic knowledge about inheritable traits for a long time. Besides being used extensively by farmers and herders across the world, the knowledge was used to justify monarchical and aristocratic systems through ideas about good "breeding".
Most of the time the artificial selection is caused by humans accidentally. For example when growing wheat the plant that produces most seeds is the most likely to get one to the ground after harvest. In animals it gets a bit more complicated. Most of the time it's just about making sure that the ones that produce most of the items in the best quality you want breed. If it's related to offspring, for example eggs and milk, it can happen naturally with human pressures. But in dogs you just throw away the ones you can't use, you end up with "better" dogs for your needs.