Dogs bark at squirrels because they get easily frustrated by an unknown animal. Squirrels move in an erratic way which instantly gets on a dog's nerves, hence the barking.