\boxed requires curly braces to enclose its argument; otherwise, it will only affect the first character after the command. However, if you try to do something like
then you will obviously get errors during compilation (due to the unbalanced braces in the arguments of \newenvironment). Some days ago, a similar problem was posed in this thread: