A barnyard animal is any animal raised on a farm. These are often referred to as farm animals in common parlance, although 'barnyard' is the more appropriate term for referring to the area of a farm containing animals. Because domesticated animals have traditionally played an important role in our lives, this is one of the big categories that we expect young children to learn in their early education -- generally somewhere around 4-5 years of age. While learning categories has educational value beyond the inherent value of the category in question, 'barnyard animals' is currently one of the more abstract categories we ask our children to learn, as the average 5-year-old city dweller probably has not seen many sheep or goats.
While the specific animals included in the category 'barnyard animals' will vary from culture to culture and from place to place, the 'core' set in America is something like this:
This core set usually has at least one or two members added to it, and may sometimes be expanded to include a dozen or more animals. The expanded set may include, among others:
You may notice that these groups are not very targeted. They mix food animals with helper animals, common food animals with uncommon (we eat a lot of pork in America, but very little mutton), and common animals with uncommon. Generally, we do not make a point of teaching kids which of these are animals are intended for slaughter, which provide services, and which provide useful byproducts. We do, however, often emphasize the sounds that they make.
In the US school system barnyard animals are not considered part of the Common Core curriculum, but they are very much ingrained in our culture, and most children still learn them in pre-k or kindergarten. This is not a bad thing, but it is questionable if this is age-appropriate. If you find yourself buying your child a book about barnyard animals, you may wish to think twice. Aside from the fact that many of us are not entirely comfortable teaching our children about where meat comes from in the form of cutesy cartoons, thus making the whole exercise moot, the vocabulary used to properly refer to barnyard animals is quite complex; even if you do not worry about the difference between cows and cattle and oxen, these animals are often referred to with irregular plurals, confusing terms for adult vs. offspring, and perhaps most importantly, often don't have any real-world examples available, leaving children to picture a pig as a primitive cartoon caricature with no significant correlation to the actual beast.
Wouldn't it really be much more educational to buy that book on shapes or the alphabet? Animals are really more of an 8-year-old gross-out type of subject, anyway.