Why don't Michonne's pets try to attack her?
Basically, because they can't. They have no arms or teeth. The fact that they stopped trying to do so implies that they somehow learned that it would never work, but how they learned this (since zombies can't learn) is never really explained. All we know is what we're told.
In the comics:
These two stopped trying to attack me a long time ago.
- Michonne, Issue 19; Volume 4: The Heart's Desire
On the show:
Pretty impressive, really, major kudos for ingenuity. Take away their arms so they can't grab you, take away their jaws so they can't bite you, take away their ability to eat, they lose interest in doing so. They're no longer in attack mode, we can be in their presence without threat. They become docile, in a sense.
- Milton, Season 3 Episode 3: Walk With Me
Why do the pets seem to obey Michonne sometimes?
We don't know.