Let $X=\{(x,\{y,z\}):y\neq z,xy,xz\in E\}$. We will double count $X$. First, by fixing $x\in V$, we see that $$|X|=\sum_{x\in V}|\{\{y,x\}:(x,\{y,z\})\in X\}|=\sum_{x\in V}{\deg(x)\choose 2}.$$
On the other hand, we can fix the pair $\{y,z\}$. Now, notice that $\{x:(x,\{y,z\})\in X\}=N(y)\cap N(z)$ where $N(y)$ denotes the neighborhood of $y$. Now, if $|N(y)\cap N(z)|\geq 2$, then $G$ would have a copy of $C_4$, which is not the case, so $|N(y)\cap N(z)|\leq 1$ for all $y\neq z\in V$. Therefore, $$|X|=\sum_{\{y,z\}\in{V\choose 2}}|N(y)\cap N(z)|\leq \sum_{\{y,z\}\in {V\choose 2}}1={n\choose 2}.$$
Now, the function $f:\mathbb{R}\to\mathbb{R}:x\mapsto{x\choose 2}$ is convex, so we can apply Jensen's inequality to find
$$ {n(n-1)\over 2}={n\choose 2}\geq |X|=\sum_{x\in V}{\deg(x)\choose 2}\geq n{{1\over n}\sum_{x\in X}\deg(x)\choose 2}=n{2{|E|\over n}\choose 2}=n{2{|E|\over n}(2{|E|\over n}-1)\over 2}.$$ Solving this equaltion for $|E|$, we see that $$|E|\leq{n\over 4}\bigl(1+\sqrt{4n-3}\bigr)$$