At the end of the first year, the correct formula is this one:
[tex]P=P_0(1+r)[/tex]
The second year, we add r times the above amount, we get:
[tex]P_0(1+r)+r(P_0(1+r))=P_0(1+2r+r^2)\\=P_0(1+r)^2[/tex]
Iterating the process, we get the general formula of any number of years:
[tex]P=P_0(1+r)^n[/tex]