This is Theorem of Frobenius (1895). The following proof is mixture of arguments of Wielandt, Krull and Gallagher.
Let $p^r$ be any divisor of $|G|$. Write $|G|=p^r.m$. Here $p$ may or may not divide $m$.
Let $X$ be the collection of all subsets of $G$ of order $p^r$. Then
$|X|=\binom{p^rm}{p^r} $.
By orbit-stabilizer theorem
$$ p^rm=|G|=|\mathcal{O}(A)|.|Stab(A)|.$$
Claim 1. If $1\in A$ then $Stab(A)\subseteq A$:
\begin{align*}
g\in Stab(A)\hskip2mm \Longrightarrow\hskip2mm gA=A \hskip2mm \Longrightarrow\hskip2mm g.1\in g.A=A \hskip5mm (\mbox{as }1\in A) \hskip2mm\Longrightarrow\hskip2mm Stab(A)\subseteq A.
\end{align*}
Claim 2. $|Stab(A)|$ divides $|A|=p^r$.
Since for $g\in Stab(A)$ we have $gA=A$ hence
$Stab(A).A=A$
which implies that $A$ (on RHS) is union of right cosets of $Stab(A)$, say
$$Stab(A).a_1 \cup Stab(A) a_2 \cup \cdots \cup Stab(A).a_r=A.$$
Hence $|Stab(A)|$ divides $|A|=p^r$. This proves Claim 2.
Write $X$ as disjoint union of orbits,
$$X= \mathcal{O}(A_1) \cup \mathcal{O}(A_2)\cup \cdots \cup \mathcal{O}(A_t),$$
and we may assume that $1\in A_i$ for each $i$ (for, $A_i$, being subset of $G$, contains some $x\in G$ and then
$\mathcal{O}(x^{-1}A_i)=\mathcal{O}(A_i)$ with $1=x^{-1}x\in x^{-1}A_i$.)
Claim 3. $\mathcal{O}(A_i)=m\Longleftrightarrow A_i$ is subgroup of order $p^r$.
Since $1\in A_i$, hence $Stab(A_i)\subseteq A_i$. Then, with Claim 1,
$$ |\mathcal{O}(A_i)|=m \Longleftrightarrow |Stab(A_i)|=p^r=|A_i| \Longleftrightarrow Stab(A_i)=A_i.$$
Claim 4. $\mathcal{O}(A_i)=m \Longleftrightarrow \mathcal{O}(A_i)$ is coset space of subgroup $A_i$ (i.e. $\mathcal{O}(A_i)=G/A_i$).
If $\mathcal{O}(A_i)$ is coset space $G/A_i$, then $|\mathcal{O}(A_i)|=|G/A_i|=m$. Conversely, if $|\mathcal{O}(A_i)|=m$ then by Claim 3, $A_i$ is subgroup of order $p^r$,
hence $\mathcal{O}(A_i)=\{gA_i\colon g\in G\}=G/A_i.$
By Claim 3 and 4, we have a bijection
$$
\begin{Bmatrix}
\mbox{orbits of order $m$}\end{Bmatrix} \longleftrightarrow \begin{Bmatrix}\mbox{ subgroups of order $p^r$}
\end{Bmatrix}.
$$
Note that if $|\mathcal{O}(A_i)|\neq m$ then $Stab(A_i)$ is proper subset of $A_i$, hence $|Stab(A_i)|$ strictly divides $p^{r}$, hence $|\mathcal{O}(A_i)|=|G|/|Stab(A_i)|=(p^rm)/|Stab(A_i)|$,
which is divisible by $pm$.
Thus, if there are $k$ subgroups of order $p^r$, then there will be $k$ orbits of size $m$, say $\mathcal{O}(A_1)$, $\mathcal{O}(A_2)$, $\cdots$, $\mathcal{O}(A_k)$ and the other orbits have size divisible by $pm$.
Then
\begin{align*}
X= \begin{Bmatrix} \mathcal{O}(A_1) \cup \cdots \mathcal{O}(A_k)\end{Bmatrix} \cup
\begin{Bmatrix} \mathcal{O}(A_{k+1}) \cup \cdots \mathcal{O}(A_t)\end{Bmatrix}
\end{align*}
The first $k$ orbits have size $m$ and the remaining have size divisible by $pm$, hence
$$\binom{p^rm}{p^r}=|X|\equiv km \pmod {pm}.$$
This congruence relation depends only on order of $G$; not on structure of $G$. Hence, in particular, if $G$ is cyclic (of order $p^rm$),
then the number of subgroups of order $p^r$ is $1$ i.e. $k=1$, we get
\begin{align*}
|X|\equiv m \pmod {pm}.
\end{align*}
Thus
$$km\equiv m \pmod {pm}, k\equiv 1 \pmod p.$$
(Thanks for the patience :))