Even though the standard term for these combinations of an auxiliary + -n't is "contractions", grammatically they act like single, indivisible words*; rather than like two words slurred together (though that was evidently their historical origin). This single word is a auxiliary, so it goes in the normal position for an auxiliary in an interrogative sentence: after the question-word and before the subject.
Why wouldn't it be valid?
Question word - auxiliary - subject - [rest of sentence]
When you use "would not," on the other hand, you have two words: the auxiliary "would", and the distinct word "not" (a word that doesn't fit very well into the general part-of-speech categories). The auxiliary again goes into the normal position for an auxiliary. The word "not" has its own, different rules for where it goes in a sentence.
Why would it not be valid?
Question word - auxiliary - subject - [rest of sentence]
*In fact, some linguists think the negative suffix in these words is best analyzed as an inflection in modern English, like the suffix "-s" used in third person.