In logic, a counterexample is simply an example that proves the conclusion made in a statement to be false. In the statement you have provided, the hypothesis is "if an animal has four legs" and the conclusion is "then it is a dog." A counterexample would be any example that fulfills the hypothesis but is contrary to the conclusion.
In other words, any example of an animal with four legs is a counterexample to this statement if the animal is not a dog. Of course, there are all kinds of animals with four legs that are not dogs. Each of these animals (elephant, cheetah, horse, cow, pig) is a counterexample because it has four legs but is not a dog.