Hi Ikumi,
Thanks for sharing your tentative patch.
The "always-align nil" behavior looks good to me.
As for the "always-align t" case, there are still some natural "broken" examples, as you know:
#+begin_src latex
\begin{equation*}
g = \begin{pmatrix}
a & b \\
c & d \\
\end{pmatrix},
\quad
h = \begin{pmatrix}
x & y \\
z & w \\
\end{pmatrix}.
\end{equation*}
#+end_src
#+begin_src latex
The matrix $\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}$ has determinant
\begin{equation*}
a d - b c.
\end{equation*}
The matrix $\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}$ has determinant
\begin{equation*}
a d - b c.
\end{equation*}
The matrix $\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}$ has determinant
\begin{equation*}
a d - b c.
\end{equation*}
#+end_src
With a bit more massaging, it should be possible to avoid these. I had in mind modifying LaTeX-indent-level-count (or the block surrounding where it is called) in \end{TABULAR} cases, adjusting by the difference between the matching \begin and its beginning of line.