Both in the books and the movies, it has been shown on multiple occasions that the Whomping Willow attacks anyone within the range of its branches.
However, in HP:PoA I noticed that the tree didn't attack Sirius (in his dog-form) when he dragged Ron through the passage. From HP:PoA book,
Harry lunged forward, he seized a handful of the brute’s hair, but it was dragging Ron away as easily as though he were a rag doll —
Then, out of nowhere, something hit Harry so hard across the face he was knocked off his feet again. He heard Hermione shriek with pain and fall too. Harry groped for his wand, blinking blood out of his eyes — “Lumos!” he whispered.
The wandlight showed him the trunk of a thick tree; they had chased Scabbers into the shadow of the Whomping Willow and its branches were creaking as though in a high wind, whipping backward and forward to stop them going nearer.
Chapter 17. Cat, Rat and Dog
The tree went for Harry and paid no attention to Sirius.
And it has been mentioned that Padfoot, Wormtail and even Crookshanks were able to walk through and press the knot that froze the tree.
So, why doesn't the tree attack animals (or wizards in animal form)? Or was it grown only to attack humans/or keep humans away?