I have read all the posts on this error that I can find. None of the solutions end up with the correct layout that this code does (left aligned, a=1 in rear). My issue is that it throws a $ added error.
\documentclass[12pt]{exam}
\usepackage{amsmath}
\begin{document}
$f(x)=$
\begin{cases}
x+2,& \text{if}\ x\geq 1 \\
x-2,& \text{if}\ x<1
\end{cases}, \ \ $a=1$
\end{document}