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)$
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$.