Equivalent definitions of a $p$-group
Formally, a $p$-group is a group in which every element has order a power of $p$. This includes the possibility that the group be infinite. For example, the Prüfer $p$-group is a $p$-group, but infinite.
For finite groups, this is equivalent to the order of the group itself being a power of $p$; Lagrange's Theorem yields that if $|G|=p^n$ and $g\in G$, then $|g|$ divides $p^n$, hence is a power of $p$. Conversely, if $G$ is a $p$-group and $q$ is a prime that divides $|G|$, then by Cauchy's Theorem $G$ has an element of order $q$, and thus $q$ must be a power of $p$; that is $q=p$. Therefore, the only prime that divides $|G|$ is $p$, hence $|G|$ is a power of $p$, as claimed.
If a finite group $G$ has order $p^a$ for some prime number $p$, then every element has order a power of $p$. This follows from the fact that the order of an element is the order of the cyclic subgroup it generates and Lagrange's theorem. Conversely, suppose that every element of $G$ has order a power of $p$, but $|G|=p^a \cdot m$, where $\gcd(p,m)=1$ and $m>1$. I claim that this leads to a contradiction. For if $q$ is a prime (necessarily distinct from $p$) which divides $m$, then an element having order $q$ exists either by an appeal to Cauchy's theorem or Sylow's theorem(s).