Most children don't listen to their parents every time. It takes a few years before children consistently know the rules and follow them.
Your child may be misbehaving for a number of reasons:
Your child might be trying particularly hard to be independent - this begins to happen a lot around the age of two, but continues off and on throughout the growing-up years.
Your child may be afraid to do what you ask, or may be resentful and overwhelmed in certain situations. This can easily happen if you have not prepared your child for new situations - like a visit to a friend or relative's home. Your child may feel he has no say at all in what happens if you don't ask him for his input.
Sometimes your child may not be old enough to be able to resist temptation and to follow the rules. Young children find it hard to control their behaviour at times, and it takes many trials and errors before children really learn to follow rules.
Your child may just be an unusually determined child - a characteristic that can be very positive when she becomes an adult. Especially if you and your child are able to learn not to let this strong will interfere with how the two of you get along. If your child is very strong-willed, you will need to develop great patience and fortitude to eventually get your points across. You may also need to enlist others, such as grandparents and close friends, to help back you up, as well as to give you relief.
All children, whether they appear to be obedient or not, need to feel understood. They need to know you and others value their feelings and ideas about how to change a situation. Help your children talk to you about what behaviour is appropriate for different situations. Even if you can't always approve or agree with their point of view, your children need to know you respect them. When children feel that way, then there's more chance they'll want to do as you ask.