Decisions of which law supersedes another are more often than not up to judges, and sometimes juries, in cases like this. Other laws can be written which try to settle the questions, too, but by and large it's the court cases which settle precedent.
This is why who gets to be a judge is such an important question. At the end of the day, the decisions of individual people who are judges can hold an incredible amount of power... and so long as their decisions are well reasoned (or well rationalized)... they can determine how we can live (or not live) our lives.
(edited for clarity)
So the more specific rule of "States may ask for SSN's for tax purposes" would override the general rule of "States may not ask for SSN's". And the exception was presumably enacted after the general rule, since otherwise there would have been no need to make an exception.
I think you might enjoy:
THE MYTH OF THE RULE OF LAW