\documentclass[preview,border=1pt]{standalone}
\usepackage{amsmath,amssymb,amsthm}


\begin{document}

\begin{alignat*}{2}
f(x) &= \sum_{k=0}^\infty x^k && \text{(by definition)} \\
&= 1+x+x^2+x^3+x^4+\dots &\quad& \text{(writing things out)} \\
&= \frac{1}{1-x} && \text{(geometric series formula)}
\end{alignat*}
\end{document}