See Why is \[ ... \] preferable to $$ ... $$? for some reasons why not using $$ in LaTeX.
What happens in your case? You're typesetting a horizontal box and in this context $$ just makes an empty math formula (the rule is explained in the TeXbook). Thus \underbrace{3} appears outside math mode and you get the error.
The same happens in \makebox[100px]{asdf $$3$$}: you get “asdf”, a space, an empty math formula, “3” and another empty math formula; however, 3 is not illegal in text mode and you get output without errors.
Display math mode makes no sense in the argument to \makebox anyway. Just use
\makebox[100pc]{asdf $\underbrace{3}$}
(you need quite a wide sheet of paper for this, because it's over 40 centimeters or 16 inches, even a bit wider than ISO A2 paper).
$$in LaTeX to begin with. Display math mode doesn't make any sense in a\makeboxanyway, use a single$. By the way, it's quite likely thatpxmeans something very different from what you think. – egreg Oct 01 '16 at 16:28$$? (Yes thepxshould have beenpc.) – flawr Oct 01 '16 at 16:30