If
$$ 
T=
\left[
\begin{array}{cccc}
   e^{\beta J} & e^{-\beta J} \\
   e^{-\beta J} & e^{\beta J} \\
\end{array} \right]
$$
and
$$Z = \sum_{S_i=\pm 1} ... \sum_{S_N=\pm 1} \exp{\beta J(\vec{S_1}\vec{S_2}+\vec{S_2}\vec{S_3}+...+\vec{S_{N-1}}\vec{S_N}+\vec{S_N}\vec{S_1})}
$$

Then why can we say that
$$Z = \sum_{S_i=\pm 1} ... \sum_{S_N=\pm 1} \langle S_1|T|S_2\rangle\langle S_2|T|S_3\rangle...\langle S_N|T|S_1\rangle ?
$$