This is a commonly mistaken as a 'contradiction' which also ignores context. Matthew 7 is not dealing with judging in of itself, rather, it speaks of hypocrisy - judging others by standards that one does not live by.
Asking questions is very important. It helps us learn, understand, and connect with others. We must continuously question ourselves and others to verify we are on the correct path.