Suppose $M$ is a finitely generated module over a commutative ring $R$. I was thinking about the relation between $\operatorname{End}_R M$ and $M_n(R)$. Suppose I fix a generating set $m_1, \dotsc, m_n \in M$.
Not all matrices $(a_{ij}) \in M_n(R)$ represent $R$ linear self-maps of $M$ via
$$m_i \mapsto \sum_j a_{ij}m_j,$$
because some of them don't respect the relations that may hold between the $m_i$. If a relation holds on $m_i$, the same had better hold for the columns of $a_{ij}$. For example, in $\mathbb{Z}_2 \oplus \mathbb{Z}_3$, with the usual two generators, the matrix
$$\begin{pmatrix} 0 & 1 \\ 1 & 0\end{pmatrix}$$
does not represent a map of abelian groups. So we need to look at some subalgebra $S Further, the fact that there are relations between the generators means that in general a lot of matrices correspond to the zero transformation. So it seems we should think of $\operatorname{End}_R M$ as a quotient of $S$, by the ideal of matrices that determine the zero transformation. I see no reason why this would be a two-sided ideal in $M_n(R)$, but it will be in $S$. So it seems that when we try to do matrix computations when working with f.g. modules, like when we prove Cayley-Hamilton and so forth, we are looking at $$M_n(R) \hookleftarrow S \twoheadrightarrow S/I \cong \operatorname{End}_R(M)$$ and we work so that we can do some matrix computations inside $S$ that work after we mod out by $I$. (I guess in proving Cayley Hamilton, like here, we're taking the ring to be $R[x]$.) Can anyone offer any more clarifying perspective? I've never seen sources that discuss it like this, so any references are welcome.