Not all kids do this, because it's 99% of the time it's a reaction / learned behavior. Some kids do it because they react in a certain way (see #4) while others react in different ways.
As adults we are *constantly* asking kids questions we know the answers to. Kids respond to that in one or more of a variety of ways:
1 - Answering, for a variety of reasons
2 - Coming to the conclusion that most adults are pretty stupid
3 - Coming to the conclusion that some adults think they, the child, are stupid
4 - Coming to the conclusion that one is SUPPOSED to ask questions they already know the answer to as part of daily life
5 - Coming to the conclusion that the "right" answer to a static question might change over time. "Are you hungry?" has different answers, so perhaps static questions like "colors" have different answers. So they're checking something they THINK they have the answer correct, because maybe red is only red on tuesdays, and it changes on wednesdays. Or in the morning, or when it's raining. It's a valid response. Word TENSES change based on time (and in some languages based on what sex the speaker is or object is (la, le in French is a good example... for sex of the speaker, Latin is a prime example of all of the above), or the listener. Meanwhile; Du versus Sie in German is a good example.
The one I find *hilarious* is number 3. Because it results in one of a few things: the "look" (what is WRONG with you? I've know what color a firetruck is for YEARS), OR a wrong answer. Really? You're REALLY going to ask me that? Okay, fine. Blue.
The 1% of the time it is NOT a learned behavior is when the child is seeking depth. For example there are about 50 shades of blue. Turquoise is always blue, as is "sky blue", but blue is not always turquoise. Also a color can change versus the light. A black dog may show a lot of red in the sunshine OR a lot of white. Is it still considered black?
((Yes, my percentages are made up. As far as I know there have been no studies done on this... the percentages are based off of my observation only.))
Another HILARIOUS thing to "do" with kids when they little (3-5 is primetime) is to ask them something REALLY obvious in a clueless tone of voice. Because they freeze. Deer in headlights freeze. This is why teachers are trained to use the phrase "Tell me about ____obvious thing_____".
ex) A good friend of mine was babysitting. She went upstairs after locking up after the parents and found the 5 year old shaving the dog. She WAS a teacher, but the words slipped out anyway;
"What are you DOING???"
The little girl, as expected, froze and just stared at her.
"I don't know."
My friend's brain kicked into gear and she knelt down and asked:
"Honey, why are you shaving the dog?"
The girl relaxed and looked at my friend and answered:
"Doggie has chemo."
Kids FREAK out when they actually believe for a moment that an adult has no idea what they are doing. The little girl had THOUGHT she was shaving the dog. It was really obvious to her that she was shaving the dog. When her babysitter saw her, though, she had no idea what she was doing. So maybe she WASN'T shaving the dog. So they *usually* answer "I don't know." because at that moment, they really DON'T. They had thought they knew what they were doing, but apparently they were wrong, so what on earth WERE they doing???
So it's an early childhood development trick to *never* ask a child *what* they are doing. Why is fine, tell me about it is fine, but "what" creates panic for a certain age group. It doesn't last for too long... but it's across the board and all cultures that this q has been posed by anthropologists and psychologists. But the child has to actually believe the adult doesn't know. They usually confuse "shock" with not knowing. Look at a toddlers face when they learn something new, and you'll see why. Their expression looks shocked until they absorb the answer. And even as adults we parallel our own facial expressions and others as meaning the same things. It's why we "believe" good actors, but bad actors are almost painful to watch.