Definition. A subgroup $P$ of a group $G$ is said to be a Sylow $p$-subgroup ($p$ prime) if $P$ is a maximal $p$-subgroup of $G$.
Theorem. Let $|G|=p^{n}m$ with $p$ prime, $n\ge 1$ and $\gcd(p, m)=1$. Let $H$ be a $p$-subgroup of $G$. Then $H$ is a Sylow $p$-subgroup of $G$ iff $|H|=p^{n}$.
I have a problem in the 'if' part of the proof, which goes as follows:
Proof. ($\implies$) Let $H$ be a Sylow $p$-subgroup and $|H|=p^{i}$, where $1\le i < n$. Then (by Sylow's first theorem$^1$) there exists $H'\le G$ such that $|H'|=p^{i+1}$ and $H \trianglelefteq H'$. Because $H$ is a maximal $p$-subgroup of $G$, it must be that $H=H'$, which is clearly not possible since $|H|\neq |H'|$. We thus have a contradiction and so $|H|=p^{n}$.
Question. Why does maximality imply that $H=H'$, and not $H'=G$?
$^1$Theorem Let $G$ be a group of order $p^{n}m$, with $n\ge 1$, $p$ prime, and $\gcd(p, m)=1$. Then,
(1) $G$ contains a subgroup of order $p^{i}$ for each $1\le i\le n$, and
(2) if $H\le G$ is such that $|H|=p^{i}$, where $1\le i < n$, then there exists some $H'\le G$ such that $|H'|=p^{i+1}$ and $H \trianglelefteq H'$.
If $H$ is a Sylow $p$-subgroup according to your Definition (maximality), then $|H|=p^n$ because such a maximal (in the hypothesis of your Theorem) $p$-subgroup does exist by Sylow's First Theorem.