  We prove a Khintchine-type recurrence theorem for pairs of endomorphisms of a
countable discrete abelian group. As a special case of the main result, if
$\Gamma$ is a countable discrete abelian group, $\varphi, \psi \in
End(\Gamma)$, and $\psi - \varphi$ is an injective endomorphism with finite
index image, then for any ergodic measure-preserving $\Gamma$-system $\left( X,
\mathcal{X}, \mu, (T_g)_{g \in \Gamma} \right)$, any measurable set $A \in
\mathcal{X}$, and any $\varepsilon > 0$, the set of $g \in \Gamma$ for which
$$\mu \left( A \cap T_{\varphi(g)}^{-1} A \cap T_{\psi(g)}^{-1} A \right) >
\mu(A)^3 - \varepsilon$$ is syndetic. This generalizes the main results of
(Ackelsberg--Bergelson--Shalom, 2022) and essentially answers a question left
open in that paper (Question 1.12).
  For the group $\Gamma = \mathbb{Z}^d$, we deduce that for any matrices $M_1,
M_2 \in M_{d \times d}(\mathbb{Z})$ whose difference $M_2 - M_1$ is
nonsingular, any ergodic measure-preserving $\mathbb{Z}^d$-system $\left( X,
\mathcal{X}, \mu, (T_{\vec{n}})_{\vec{n} \in \mathbb{Z}^d} \right)$, any
measurable set $A \in \mathcal{X}$, and any $\varepsilon > 0$, the set of
$\vec{n} \in \mathbb{Z}^d$ for which $$\mu \left( A \cap T_{M_1 \vec{n}}^{-1} A
\cap T_{M_2 \vec{n}}^{-1} A \right) > \mu(A)^3 - \varepsilon$$ is syndetic, a
result that was previously known only in the case $d = 2$.
  The key ingredients in the proof are: (1) a recent result obtained jointly
with Bergelson and Shalom that says that the relevant ergodic averages are
controlled by a characteristic factor closely related to the quasi-affine (or
Conze--Lesigne) factor; (2) an extension trick to reduce to systems with
well-behaved (with respect to $\varphi$ and $\psi$) discrete spectrum; and (3)
a description of Mackey groups associated to quasi-affine cocycles over
rotational systems with well-behaved discrete spectrum.
