I think is simple. All are due to algebraic units. If $z=a+b\sqrt{d}$ is a unit and $N(z)=a^2-d\cdot b^2$, then $N(z)=1$ (unit). Hence if we deal with algebraic units, then $N(z)=1=a^2-d\cdot b^2$, is a Pell equation.
See paper [1] (the knowledge of elliptic singular modulus $k_r$ requires the knowledge of algebraic units).
It have been proven that most of these formulas (Ramanujan formulas for $1/\pi$, $1/\pi^2$, etc) rise from elliptic functions (see [3],[5],[6]). For example:
Set
$$
\phi(z):={}_3F_2\left(\frac{1}{2},\frac{1}{2},\frac{1}{2};1,1,z\right)=\frac{4K^2\left(\sqrt{\frac{1}{2}\left(1-\sqrt{1-z}\right)}\right)}{\pi^2}
$$
Then we ask whether exist constants $a_1,b_1$ and $g$ such that
$$
\sum^{\infty}_{n=0}\frac{\left(\frac{1}{2}\right)_n^3}{(n!)^3}z^n(a_1n+b_1)=\frac{g}{\pi}\leftrightarrow b_1\phi(z)+a_1\phi'(z)=\frac{g}{\pi}.
$$
Setting $w=\sqrt{\frac{1}{2}\left(1-\sqrt{1-z}\right)}$, then $1-2w^2=\sqrt{1-z}$.
Also by direct calculation
$$
\sum^{\infty}_{n=0}\frac{\left(\frac{1}{2}\right)_n^3}{(n!)^3}4^n(w-w^2)^n(a_1n+b_1)=\frac{4K(w)\left[a_1E(w)+(b_1-a_1(1-w)-2b_1w)K(w)\right]}{\pi^2(1-2w)}
$$
Here ofcourse $K(w)$ and $E(w)$ are the complete elliptic integrals of the first and second kind. Also
$$
\alpha(r)=\frac{\pi}{4K^2(k_r)}-\sqrt{r}\left(\frac{E(k_r)}{K(k_r)}-1\right)
$$
where $k_r$ is the elliptic singular modulus i.e the solution of
$$
\frac{K(\sqrt{1-k_r^2})}{K(k_r)}=\sqrt{r}, r>0.
$$
Also
$$
\frac{dK(x)}{dx}=\frac{E(x)}{x(1-x^2)}-\frac{K(x)}{x}
$$
Hence setting $w=k_r$, $a_1=1$ and $b_1=\left(\frac{\alpha(r)}{\sqrt{r}}-k_r^2\right)\left(1-2k_r^2\right)^{-1}$ we arrive to the general formula
$$
\sum^{\infty}_{n=0}\frac{\left(\frac{1}{2}\right)_n^3}{(n!)^3}4^n(k_rk'_r)^{2n}\left(n+\frac{\alpha(r)-k_r^2\sqrt{r}}{\sqrt{r}(1-2k_r^2)}\right)=\frac{1}{\pi\sqrt{r}(1-2k_r^2)}
$$
Evaluations of $k_r$ and $\alpha(r)$ can given for positive rationals $r$. For example with $r=2$, we have $k_2=\sqrt{2}-1$, $\alpha(2)=\sqrt{2}-1$. Hence we get the next formula
$$
\sum^{\infty}_{n=0}\frac{\left(\frac{1}{2}\right)_n^3}{(n!)^3}(40\sqrt{2}-56)^{n}\left(n+\frac{2}{7}-\frac{1}{7\sqrt{2}}\right)=\frac{8+5\sqrt{2}}{14\pi}
$$
For $r$ positive integer we can find $k_r$ and $\alpha(r)$ using methods of [1],[2]. For a table of values of $k_r$ from r=1 to 100 see [4]. For evaluations of $\alpha(r)$ see[5]
[1]: Mark B. Villarino: "Ramanujan most singular modulus". arXiv:math/0308028v4 [math.HO] 2005.
[2]: D. Broadhurst. "Solutions by radicals at Singular Values $k_N$ from New Class Invariants for $N\equiv3(\textrm{mod})8$". arXiv:0807.2976 [math-ph], (2008).
[3]: N.D. Bagis, M.L. Glasser. "Ramanujan type $1/\pi$ approximation formulas". Journal of Number Theory, Elsevier., (2013)
[4]: J.M. Borwein, M.L. Glasser, R.C. McPhedran, J.G. Wan, I.J. Zucker. "Lattice Sums Then and Now". Cambridge University Press. New York, (2013).
[5]: J.M. Borwein and P.B. Borwein. "Pi and the AGM". 1987 ed., New York: John Wiley and Sons Inc., (1987)
[6]: N.D. Bagis. "A General Method for Constructing Ramanujan-Type Formals for Powers of $1/\pi$". The Mathematica Journal. Vol. 15., (2013)
...CONTINUED
From Chan Huang's Unit Theorem we have that: If $n\equiv 2(mod4)$, then $k_n$ is unit.
From relation
$$
\frac{(k'_n)^2}{k_n}=2g_n^{12}\textrm{, }k'_n=\sqrt{1-k_n^2}
$$
where $g_n$ is Weber's invariant:
$$
g_n=2^{-1/4}q^{-1/24}\prod^{\infty}_{m=0}(1-q^{2m+1})\textrm{, }q=e^{-\pi\sqrt{n}}.
$$
Now if $\delta_1,\delta_2,\ldots,\delta_{\nu(-8n)}$ are the distinct odd divisors of $-8n$ and $\delta'_l$ are the complimentary divisors of $\delta_l$, such $\delta'_l\delta_l=-8n$
$$
g_{2n}=\prod^{\nu(-8n)}_{l=1}\left(\frac{T_l+U_l\sqrt{\delta_l}}{2}\right)^{\nu(\delta_l)\nu(\delta'_l)/\nu(-8n)},
$$
where $\nu(n)$ is the number of properly primitive classes of discriminant of $n$ and $(T_l,U_l)$ is the minimal solution of the Pell equation
$$
x^2-\delta_l y^2=4
$$
NOTES.
LEMMA 1.
If
$uv:=g_n^6$
$2U:=u^2+u^{-2}$, $2V=v^2+v^{-2}$
$W=\sqrt{U^2+V^2-1}$,
$2S=U+V+W+1$, then
$$
k_n^2=(\sqrt{S}-\sqrt{S-1})^2(\sqrt{S-U}-\sqrt{S-U-1})^2(\sqrt{S-V}-\sqrt{S-V-1})^2\times
$$
$$
\times(\sqrt{S-W}-\sqrt{S-W-1})^2.
$$
LEMMA 2.
If
$\sqrt{\alpha}:=\sqrt{ab}+\sqrt{(a+1)(b-1)}$
$\sqrt{\beta}:=\sqrt{cd}+\sqrt{(c-1)(d-1)}$, then
$$
x_1:=(\sqrt{a+1}-\sqrt{a})(\sqrt{b}-\sqrt{b-1})(\sqrt{c}-\sqrt{c-1})(\sqrt{d}-\sqrt{d-1})
$$
$$
x_2:=-(\sqrt{a+1}+\sqrt{a})(\sqrt{b}+\sqrt{b-1})(\sqrt{c}+\sqrt{c-1})(\sqrt{d}+\sqrt{d-1})
$$
are roots of
$$
x-x^{-1}=2(\sqrt{\alpha\beta}+\sqrt{(\alpha+1)(\beta-1)})
$$