Proving a property of groups assuming they are abelian or they have a prime divisor 
Let $n \in \mathbb{N}, n \geq 3$ be an odd number and $(G, \cdot)$ a group with $2n$ elements. Let $A=\{x^2 \mid x \in G\}$. Show that $\lvert A \rvert = n$ if at least one of the following conditions is true:
\begin{gather}
\begin{aligned}
a)\, &(G, \cdot) \text{ is abelian} \\
b)\, &n \text{ is a prime number} 
\end{aligned}
\end{gather}

My approach was to first assume $b)$ and solve the problem. If $n$ is a prime odd number then $n \neq 2$ so by Cauchy's theorem there exist two elements $x$ and $y$ such that $x^2=e$, $y^n=e$, where $e$ is the identity element. Therefore, we can define $H=\{y^k \mid k \in \mathbb{Z} \}$ and $K=\{e, x\}$. It is clear that $H$ and $K$ are subgroups of $G$ and $H$ is a normal subgroup(it has an index of $2$). Now $HK=\{hk \mid h \in H \text{ and } k \in K \}, \lvert HK \rvert = \frac{\lvert H \rvert \lvert K \rvert}{\lvert H \cap K \rvert}=\frac{2n}{\lvert H \cap K \rvert}$. Therefore $H$ and $K$ only have $e$ in common and $HK=G$. If $a \in G, a \notin H$, then $a=xy^k, 0 \le k \le n-1$. If $(xy^k)^2 \notin H \implies xy^kxy^k=xy^m \implies x=y^m(y^{-a})^2 \implies x \in H $ which is a contradiction. Therefore $A$ has at most $n$ elements. How would I prove $A$ has at least $n$ elements to get the double inequality and I have no ideea how to deal with $a)$
 A: If $G$ is abelian, the map $x \mapsto x^{2}$ is a homomorphism, so its image $A$ is a subgroup. The kernel $K = \{ x \in G : x^{2} = 1 \}$ is a subgroup, which by Cauchy's lemma applied twice has order a power of $2$ greater than or equal to $2$, so by Lagrange's theorem it must have order exactly $2$. It follows that $A \cong G/K$ has order $n$.
If $n$ is a prime, then by Cauchy's lemma there is a subgroup $B$ of order $n$. Each element $b \in B$ is a square, as $b = b^{n + 1} = (b^{(n+1)/2})^{2}$, so $B \subseteq A$. On the other hand, $B$ has index $2$ in $G$, and thus it is normal. Since $G/B$ has order $2$, it follows that all squares are in $B$, so $A \subseteq B$, and $A = B$ has order $n$.

Perhaps it could be noted that the fact that $G$ has order $2 n$, with $n$ odd, implies that $A$ has order $n$ without any further assumptions. This is because such a $G$ has a subgroup of order $n$.
A: If $G$ is abelian, then the set $A$ is a subgroup. It can't be of even order. Otherwise, a larger power of $2$ would have to divide $|G|$.
Now, why is it $n$? Because there is a unique order $2$ element, $a^2=e$. If $a,b$ are order two elements, then $<a,b>$ is of order $4$ which is not possible.
If $a^2=b^2$, then $ab^{-1}$ is an element of order $2$ and by our previous argument, it is either $e$ or $a$. Therefore, $x \rightarrow x^2$ is a $\text{two-to-one}$ function. This settles Case $1$.
Now, if $|G|=2p$, there is a subgroup of order $p$, say, $H$. For every element in $g\in G-H$, look at its projection $gH\in G/H$. That element is of order $2$, which means $g^2\in H$. Therefore, $A\subset H$.
Since $H$ is cyclic of odd order, $h\rightarrow h^2$ is an isomorphism. Therefore, $A=H$.
