TeX distinguishes between text and math mode, because text and math follow very different typographic conventions. To "enforce" this distinction, math-mode commands yield errors when used in text mode. The short answer to your issue is thus "type math in math mode", i.e. $a=\frac{1}{6}$
or \(a=\frac{1}{6}\)
for inline math, or some display math environment.
As David and Wipet pointed out in their comments you should never ignore error messages; and the output you get after errors is just TeX trying to recover and hoping for the best. This output is usually rubbish. Just for fun, let us try to see what is going on wrong with the minimal code
\documentclass{article}
\begin{document}
a = \frac{1}{6}
\end{document}
When TeX encounters a
it switches to horizontal mode and starts typesetting normal text. TeX goes on and finds the letter a
, a space, the equal sign, another space (all in text mode). Now TeX finds \frac
, which is a macro defined by LaTeX as
\def\frac#1#2{{\begingroup#1\endgroup\over#2}}
and after its expansion it's effectively like your code were
a = {\begingroup1\endgroup\over6}
TeX goes on: the opening brace, \begingroup
, the number 1
, and \endgroup
(everything still in text mode) are sent to be typeset.
Now TeX finds \over
: this is a math-mode primitive, which is allowed only in math mode, so TeX assumes you forgot to enter it. Therefore it spits out the error
! Missing $ inserted.
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
and enters math mode by adding a $
, which also starts a group; now \over
recognizes what precedes it in the current group numerator, but in the math list which has been opened by the error recovery there is nothing before \over
, so the numerator is empty. Then TeX goes on, finds 6
(the denominator), and then the closing brace. Now that's a problem: where is the opening brace? It was outside of math mode, but the inserted $
opened another one, so this brace is mismatched. Therefore TeX spits out the following error
! Extra }, or forgotten $.
I've deleted a group-closing symbol because it seems to be
spurious, [...]
TeX assumes that the }
was wrong, deletes it, and still tries to go on (still being in math mode). Then in the expansion of \end{document}
TeX finds a \par
, which is allowed only in text mode, so it assumes that you forgot to exit math mode, and spits again a
! Missing $ inserted.
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
Then it inserts a $
and somehow finishes the document. Basically TeX has behaved as if you had typed
\begin{document}
a = {\begingroup1\endgroup$\over6$
\end{document}
and prints

where the a = 1
is in text mode, and the error recovery mechanism has somehow managed to give you that weird-looking fraction. Oh, yes, at the end TeX also tells you
(\end occurred inside a group at level 1)
### simple group (level 1) entered at line 3 ({)
because the opening brace was never closed (the corresponding closing brace was eliminated during the error recovering).
$a=\frac{1}{6}$
(with the dollar signs), ore use a display math environment. Please have a look at What are good learning resources for a LaTeX beginner? and What is Math Mode.