Children are inquisitive by nature. When they are younger, it's usually because they want to better understand something. When they are older, it's because they want to better understand why you think something is important and why they should also feel the same way. Regardless of their age, it's imperative that when setting forth the rules and expectations in your home, your child understands there is no room for questioning the rules you set forth and the consequences of breaking the rules.
Younger children usually do not understand a lengthy explanation of why it's important that they be home from their friend's home at a certain time or why they aren't allowed to play ball in the house. But the one thing they do strive to do most of the time is to make their parents proud and happy. So when a young child asks "Why?" or "Why not?" when they are told they can't play with something or someone or why they have to obey a rule you've set forth, simply explain to them that "because it makes me happy when you follow the house rules and do what I have asked of you." You should avoid using the term, "Because I said so," as that only adds to the child's frustration and confusion.
Older children, adolescents and teenagers alike will probably require more from your explanation. When they question "Why?" or "Why not?" it's best to directly, honestly and clearly state your reasoning. "I asked you to be home by 10 p.m. because we have to be at the dentist's office first thing in the morning for your check-up and we can't be late." It is also a great opportunity for you to reiterate the consequences of breaking the rule. "If you are not home by 10 p.m., you'll be grounded from going to your friend's house for a week." Be consistent, be firm, and be clear.
Though your child may challenge you by asking your reasoning why a rule has been put in place, it also shows their growth as an individual thinker. So try not to get angry or frustrated when they do so; realize it's their way of understanding their world around them.