I can't seem to make progress on proving the following: if $G$ finite, $P < G$ a subgroup of order $p$ and $P = C_G(P)$ then $P$ is a Sylow $p$-subgroup of $G$. $C_G(P)$ is the centralizer of $P$ in $G$, i.e. the set $\{a \in G : ax=xa \ \forall x \in P\}$.
My work so far: Since $P = C_G(P)$ then $P$ abelian. I think to show $P$ is a Sylow p-subgroup we need to show that if $|G| =mp^n$ for some $m$ coprime to $p$ and $n > 0$, then $n = 1$ (so $P$ has maximal order). There should also exist $Q$ a Sylow p-subgroup of $G$ such that $P < Q$. If we can show $P = Q$ then we are done.
I suspected a counting argument using the class equation: $|G| = |Z(G)| + \sum[G:C_G(x_i)]$ where $x_i \in G \setminus Z(G)$. If $x_i \in P$ then $P = C_G(P) \subset C_G(x_i)$ so $p$ divides $|C_G(x_i)| = p^{k_i}$ for $1 \le k_i \le n$. Then \begin{align} |G| &= |Z(G)| + \sum[G:C_G(x_i)] \\ mp^n &=|Z(G)| + |G\setminus Z(G)|p^{k_i}. \end{align} I'm not sure if I'm heading in the right direction since I don't see where we would even get a contradiction here. Thanks for any feedback.
As you say, let $Q$ be a $p$-Sylow with $P\le Q$. Applying the class equation to $Q$ shows that $Q$ has a non-trivial center, since all non-central elements have class sizes divisible by $p$, so $|Z(Q)|=1$ would imply $p$ divides $p^n-1$, which is absurd. Since $P=C_G(P)$ and since $Z(Q)$ centralizes $P$, we must have $Z(Q)\le P$ and thus $Z(Q)=P$ since $P$ has order $p$ and $Z(Q)$ has order at least $p$. But then $Q\le C_G(Z(Q))=C_G(P)=P$, so $Q\le P$. Thus $P$ is a $p$-Sylow.
If you know the full statement of Sylow's theorem, there's an even shorter proof: Since the full theorem states that any $p$-subgroup that is not Sylow is an index $p$-subgroup of some other subgroup, then if $P$ is not Sylow, $P<R$ with $|R|=p^2$. But every group of order $p^2$ is abelian and thus $R$ centralizes $P$. Contradiction.