Q:

Why does `gather` behave this way, and what can we do about it?

Here's a simplified version of the code I'm having trouble with.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}\underline{First set of identities.}\end{center}
\[x+x = x\]

\begin{center}\underline{Second set.}\end{center} \begin{gather*}
    0+x = x, \quad x+0 = 0 \\
    (x+y)+z = x+(y+z)
\end{gather*}
\end{document}

Basically, the gather* command is creating more space than the usual [\ \]. Why is gather* doing this, and what can we do about it?

A:

I'll present two possible solutions.

Don't close the center environment
“Abuse” the gather* environment

At the top is the rendering with your input. Note that I removed underlining, which is frowned upon by typographers. Instead of \textbf you can also use \textit.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}\underline{First set of identities.}\end{center}
\[x+x = x\]

\begin{center}\underline{Second set.}\end{center} \begin{gather*}
    0+x = x, \quad x+0 = 0 \\
    (x+y)+z = x+(y+z)
\end{gather*}

\bigskip
\hrule
\bigskip

\begin{center}\textbf{First set of identities.}
\[x+x = x\]
\textbf{Second set.}
\begin{gather*}
    0+x = x, \quad x+0 = 0 \\
    (x+y)+z = x+(y+z)
\end{gather*}
\end{center}

\bigskip
\hrule
\bigskip

\begin{gather*}
\textbf{First set of identities.}\\
x+x = x \\[2ex]
\textbf{Second set.}\\
0+x = x, \quad x+0 = 0 \\
(x+y)+z = x+(y+z)
\end{gather*}
\end{document}

A:

It's the center environment not playing well with gather*:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}
    \underline{First set of identities.}
    \[x+x = x\]
\end{center}%
\begin{center}
    \underline{Second set.}
    \begin{gather*}
        0+x = x, \quad x+0 = 0 \\
        (x+y)+z = x+(y+z)
    \end{gather*}
\end{center}
\end{document}

Alternatively, since there seem to be a duplication of skips, you can do an \unskip after the problematic center environment:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}
    \underline{First set of identities.}
\end{center}%
    \[x+x = x\]
\begin{center}
    \underline{Second set.}
\end{center}\unskip
    \begin{gather*}
        0+x = x, \quad x+0 = 0 \\
        (x+y)+z = x+(y+z)
    \end{gather*}
\end{document}

