This is not an answer but an extended comment that shows the importance of submitting a complete MWE. Without an MWE, one cannot reproduce your issue. If I compile
\documentclass{article}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{center}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial, accepting] (q_0) {$q_0$};
\node[state] [right=of q_0] (q_1) {$q_1$};
\path[->]
(q_0) edge node {$a,b$} (q_1)
(q_1) edge [loop above] node {$a,b$} ();
\end{tikzpicture}
\captionof{figure}{This DFA represents $L_1 = \{\lambda\}$}
\end{center}
\end{document}
I get

That means that the weird behavior you are reporting does not come from the code piece that you are showing, but from something else. In many situations, when you try to write an MWE, you actually find the source of the problem yourself, and thus learn something. So
PLEASE SUMBIT A COMPLETE MWE!
The above code qualifies as an MWE: it starts with \documentclass, ends with \end{document} and can be compiled. It is also rather minimal in the sense that (as far as I can tell) no unnecessary packages are loaded.
\mbox. – A.Ellett Oct 11 '18 at 04:52