Period after math-mode equation

You insert the period as part of the equation and therefore also in math mode, as opposed to putting it outside the equation.

enter image description here

\documentclass{article}
\begin{document}
If \[x\rightarrow y,\] then \[y\rightarrow z.\]
\end{document}

Naturally, this may lead to a slightly off-center spacing due to the punctuation (albeit marginally visible). However, to correct for this, you can use \phantom{<punct>} on the opposite side:

\documentclass{article}
\begin{document}
If \[\phantom{,}x\rightarrow y,\] then \[\phantom{.}y\rightarrow z.\]
\end{document}

Punctuation in displayed formulas should stay within the formula:

If
\[
x\to y,
\]
then
\[
y\to z.
\]

Some people leave a space before the punctuation (I don't); others completely suppress punctuation in displayed formulas, on the basis that the display is doing the work and the reader can infer commas or periods from the context.

Which style to use is a question of personal taste; the most important thing is to be coherent along the document.