formula derivation for periodic signal power
I'd like to show you a more formal derivation. Note that the first formula for arbitrary (non-periodic) signals could be rewritten as

$$P_x=\lim_{M\rightarrow\infty}\frac{1}{(2M+1)N}\sum_{n=-MN}^{(M+1)N-1}|x[n]|^2\tag{1}$$

for some integer $N\ge 1$. For $N=1$, Eq. $(1)$ is identical with the first formula in your question. If you choose $N&gt;1$ you simply add more chunks of length $N$ (instead of length $1$) to your sum if you increase $M$.

Now assume that the signal $x[n]$ is periodic with period $N$. This means that the sum over $2M+1$ periods equals $(2M+1)$ times the sum over a single period:

$$\sum_{n=-MN}^{(M+1)N-1}|x[n]|^2=(2M+1)\sum_{n=0}^{N-1}|x[n]|^2\tag{2}$$

Plugging $(2)$ into $(1)$ gives

$$P_x=\lim_{M\rightarrow\infty}\frac{1}{(2M+1)N}(2M+1)\sum_{n=0}^{N-1}|x[n]|^2=\frac{1}{N}\sum_{n=0}^{N-1}|x[n]|^2\tag{3}$$