When someone has done something wrong—polite
How could you do such a silly thing?
How could you do such a thing?
What could you have been thinking?
What on earth were you thinking?
What possessed you to do that?
What got into you?
I hope you’re sorry.
When will you ever learn?
Now what did you go and do that for? (folksy)