Statement:
Let $G$ be a finite group. Show that if for each positive integer $m$ the number of solutions $x$ of the equation $x^n=e$ in $G$ is at most $n$, then $G$ is cyclic.
There are various proofs available as answers to this post.
Inspired by this answer (which I did not find convincing), I am attempting to write a proof on my own (point out errors or fallacies, if any).
My attempt:
Define: $\mathcal S(n) := \{ g\in G \ | \ g^n=e\}$
Given: $G$ is finite and $ |\mathcal S(n)|\leq n$ for all $n\in \mathbb Z^+$.
Assumption: Suppose, if possible, $G$ be non-cyclic.
$G$ is finite $\implies$ G has at least one element (say, $x$) of maximal order $M$. $M=\max\{\DeclareMathOperator{\ord}{ord}\ord(g) \ | \ g\in G\}\tag*{}$ $G$ being non-cyclic, $M\neq |G|$, for otherwise, $x$ will generate $G$.
$G$ is non-cyclic $\implies$ $G\setminus \langle x \rangle$ is non-empty, so it has at least one element (say, $y$) of minmal order $m$. $m=\min\{\ord(g) \ | \ g\in G\setminus \langle x \rangle \}\tag*{}$
Claim 1: $\mathcal S(M) =\langle x\rangle$ and $\mathcal S(m) =\langle y\rangle$
This can be proven by a counting argument. All elements of $\langle x\rangle$ satisfy the equation $g^M=e$ so, $\langle x\rangle\subseteq \mathcal S(M)$. Now, use that fact that $|\langle x\rangle|= \ord(x)=M$ and that $|\mathcal S(M)|\leq M$.
Claim 2: $\langle x\rangle$ and $\langle y \rangle$ are normal in $G$. For all $g\in G$ and $h\in \langle x\rangle $, $(ghg^{-1})^M=gh^Mg^{-1}=e\implies ghg^{-1}\in \mathcal S(M)=\langle x\rangle\tag*{}$ Repeat the same argument for $\langle y\rangle$.
Lemma: If $H$ and $K$ are normal subgroups of any group $G$ such that $H\cap K=\{e\}$ then the elements of $H$ and $K$ commute with each other.
For all $h\in H$ and $k\in K$, $hkh^{-1}{k^{-1}}=\underbrace{(hkh^{-1})}_{\in K}k^{-1}=h\underbrace{(khk^{-1})^{-1}}_{\in H}\tag*{}$ By normality and closure, $hkh^{-1}k^{-1}\in H\cap K$ so, $hkh^{-1}k^{-1}=e$.
Now with these claims and lemmas at hand, we are equipped to proceed. There are three possible cases:
Case 1: $\DeclareMathOperator{\gcd}{gcd}\gcd(M,m)=1$.
This would mean that $S(M)\cap S(m)=\{e\}$ and hence, $\langle x\rangle \cap \langle y\rangle=\{e\}$.
Now, claim 2 followed by the lemma, we know that $xy=yx$.
$\therefore$ $\ord(xy)=\DeclareMathOperator{\lcm}{lcm}\lcm(M,m)=Mm\leq M$ ( $\because$ $M$ is the maximal order of $G$) $\iff m=1$.
Now, $\ord(y)=1\implies y=e \in \langle x\rangle$. This is a contradiction because $y$ was chosen such that $y\in G\setminus \langle x\rangle$.
We can conclude that in this case, $G\setminus \langle x\rangle$ is empty, so $G=\langle x\rangle$ as required.
Case 2: $1<\gcd(M,m)<m$
Suppose $\text{gcd}(M,m)=d$ for some $1<d<m$.
$\quad$ Claim 2.1: $y^d\not \in \langle x\rangle$.
$\ord(y^d)=m/d$. However, as a consequence of Lagrange's theorem, $\langle x\rangle $ cannot not have any element of this order because $m/d$ does not divide $M$.
In fact, $\gcd(M, m/d)=1$ because we have removed the highest possible common factor from $m$.
By the requirement that $m$ is the minimal order in $G\setminus \langle x\rangle$:
$m=\min\left(m, \ord(y^d) \right)\implies m\leq \frac{m}d \implies d=1$ which is the case 1.
Case 3: $\gcd(M,m)=m$ i.e., $m$ divides $M$.
$\ord(y)=m, \ m\ | \ M \implies y^M=e \implies y\in\mathcal S(M)=\langle x\rangle\tag*{}$ This is again a contradiction because of choice of $y\in G\setminus \langle x\rangle$.
This completes the proof. $\blacksquare$
What I did not find convincing in the linked answer:
In the linked answer, the case 2 was $d=\gcd(m,M)>1$ and the element $y^{m/d}$ was picked from $\langle y\rangle$ which is of order $d$. Then it was argued that $m$ is the minimal order so, $d\leq m$ and hence, $d=m$.
But $m$ is the minimal order of elements of $G\setminus \langle x\rangle$. How are we guaranteed that $y^{m/d}\not \in \langle x\rangle$?
I think it is possible that $y^{m/d}\in \langle x\rangle$ so it can have an order less than $m$. Am I missing out on something or is this really a flaw in the linked proof?
Update: Unfortunately, I found a mistake...The argument for claim 2.1 is false. $m/d$ may divide $M$ and it's not necessary that $\text{gcd}(m/d, M)=1$. For instance, $\text{gcd}(4,6)=2$ but $4/2$ does divide $6$. So there needs to be some way to rewrite the proof for case 2.
Based on Steve D's comments, I will rewrite the case-2 correctly.
Case 2: $1<\DeclareMathOperator{\gcd}{gcd}\underbrace{\gcd(M,m)}_{=d}<m$
The elements $x^{M/d}$ and $y^{m/d}$ both have an order of $d$ and hence, it is necessary that $\mathcal S(d)=\langle x^{M/d}\rangle = \langle y^{m/d}\rangle\tag*{}$ in order to maintain the constraint that $|\mathcal S(d)|\leq d$.
$\quad$ Claim 2.1: $x$ and $y$ commute with every element of $\mathcal S(d)$.
Consider the group $G'=\langle x, y\rangle$ which is a subgroup of $G$.
$\quad$ Claim 2.2: $\mathcal S(d)$ is a subgroup of the centre of $G'$ i.e., $\mathbf Z(G')$.
Consider the quotient group $G'/\mathcal S(d)$ which contains the cosets $\overline x= x\cdot \mathcal S(d)$ and $\overline y = y\cdot\mathcal S(d)$.
Consider the subgroups of $G'/\mathcal S(d)$ generated by the cosets $\overline x$ and $\overline y$.
$\langle \overline x\rangle = \{x^i\cdot\mathcal S(d) \ | \ i=1,2,\ldots, M/d\}\tag*{}$
$\langle \overline y\rangle = \{y^i\cdot\mathcal S(d) \ | \ i=1,2,\ldots, m/d\}\tag*{}$
$\quad$ Claim 2.3: These two subgroups are normal in $G'/\mathcal S(d)$ and their intersection is singleton identity i.e., $\{\mathcal S(d)\}$.
Using the lemma in my original post, we are assured that $\overline x$ and $\overline y$ commute over coset multiplication.
$\quad$ Claim 2.4: Every coset of $G'/\mathcal S(d)$ is of the form $(\overline x)^i (\overline y)^j$ which can be re-written as $(\overline x\overline y)^k$ because $\DeclareMathOperator{\ord}{ord}\ord(\overline x)$ and $\ord(\overline y)$ are co-prime.
Hence, $G'/\mathcal S(d) =\langle \overline x\overline y\rangle$
$\quad$ Claim 2.5: $x$ and $y$ commute in $G'$.
Hence, $\ord(xy)=\text{lcm}(M,m)=\frac{Mm}{d}$.
By definition of maximal order, we need that $\frac{Mm}{d}\leq M$ i.e., $m\leq d$ which is a contradiction.