Every parent has experienced this phenomenon at one point or another. You are having a difficult time with your child and in walks your mother or a babysitter and your child completely acts like an angel (and you want to strangle them!) I know! I've been there! Here are some reasons why children do this...
1. Lack of Patience. I used to work as a nanny and the kids listened to me 90% of the time! I arrived at 8am and left at 5pm. I had SO much patience! With my own children, however, I definitely have days that my reactions are overreactive (and are a result of unrealistic expectations). This happens OFTEN!
2. Lack of Consistency. Again, when I was a nanny I was consistent 95% of the time. Unfortunately, that's not the case as a stay at home mom and a mom on nights and weekends. I try so hard to be consistent but I definitely have my weak points...and my toddler definitely knows how to make me cave!
3. Personal feelings. As parents, we often take behaviors unrelated to us and personalize them. For instance, Joe's 2 year old son is hitting other kids and school and he feels like it's a reflection of his parenting when in fact it's probably just a result of his sons communication limitations.
Although every child has different capabilities, children are products of their environment. If your child only demonstrates these issues sometimes then chances are you are just experiencing a normal case of selective hearing (or selective outbursts)! One thing to remember is that children feel safe with you so they are more likely to express their anger or sadness at times when they need to release it. If they express their anger toward someone new they may not know the reaction they would receive.
If you feel that your child is very challenging (only towards you) then maybe it's time for some help. Look for some parenting resources such as The Happiest Toddler on the Block (one of my favorites-available on my amazon store) or call your local intermediate unit to see what help they provide to parents. Also, talk to people about the issues you are facing and chances are they will have some ideas for you!