A 95% confidence interval for a difference of proportions and a 2x2 Chi-square test of independence both try to answer the same question, in an elementary situation, using the same distribution (namely the standard normal one).
When carrying out the computations, you would expect either that they're fundamentally different for whatever reason, or that they are completely equivalent even though presented differently. Yet it turns out that the mathematical expressions that one gets are almost identical, but not quite. So my question is:
Is there a deep reason for that?
Below are the actual computations. To make the computations simpler I will assume that two samples both of the same size $N$ were taken from two populations (say males and females), where $a$ males and $b$ females were left-handed.
$$\matrix{&\text{left}&\text{right}\\ \text{males}&a&N-a \\\text{females}&b & N-b}$$
On the one hand, the 95% C.I. is given by $$\frac{a-b}{N}\pm 1.96 \sqrt {\frac{a(N-a)}{N^3}+\frac{b(N-b)}{N^3}}$$
so that the null-hypothesis (the proportion of left-handed people is the same in both genders) is rejected when $$0\notin \text{C.I.} \Leftrightarrow \frac{(a-b)^2}{\frac{a(N-a)}{N}+\frac{b(N-b)}{N}}> 3.842$$ which you can simplify as $$0\notin \text{C.I.} \Leftrightarrow \frac{N(a-b)^2 }{(a+b)N-{\color{red}{(a^2+b^2)}}}> 3.842$$
In the Chi-square approach, only the red part will be slightly different, which I find mesmerizing. Usually it means that I've made a mistake somewhere, but it doesn't look like this is the case here.
On the other hand, the expected counts are $$\matrix{&\text{left}&\text{right}\\ \text{males}&\frac{a+b}{2}&N-\frac{a+b}{2} \\\text{females}&\frac{a+b}{2} & N-\frac{a+b}{2}}$$
and the Chi-square statistic is given by $$\chi^2 = 2\left[\frac{\left(\frac{a-b}{2}\right)^2}{\frac{a+b}{2}}+\frac{\left(\frac{a-b}{2}\right)^2}{N-\frac{a+b}{2}}\right]$$
so that the same null-hypothesis is rejected when
$$(a-b)^2 \times\left[\frac{1}{a+b}+\frac{1}{2N-a-b}\right] > 3.842$$ or $$ \left[\frac{N(a-b)^2}{(a+b)N-{\color{red}{\frac{(a+b)^2}{2}}}}\right] > 3.842$$
I would be happy if this was just some computational mistake, and I would be happy if there is an insightful explanation for this.