The $(\forall \text I)$ rule is:
if $\Gamma \vdash \varphi[x/a]$, then $\Gamma \vdash \forall x \varphi$, provided that parameter $a$a is “fresh” in the sense of having no other occurrences in $\Gamma , \varphi$
The proviso is consistent with the intuitive meaning of the rule: if $\varphi$ holds of an object $a$ whatever, then it holds of every object.
The proviso is needed in order to avoid the fallacy: John is a Philosopher, therefore everything is a Philospher.
In your wrong proof above, you have committed exactly these fallacy: the parameter $a$ [in your case: John] must not occur in $\Gamma$. In your case $\Gamma = \{ P(\text {John}) \}$.
In conclusion, the issue is: how can you prove $\vdash P(\text {John})$?
Example: consider the first-order language of arithmetic with individual constants $0$ and $1$ and let $\mathsf {PA}$ the collection of first-order Peano axiom.
We have: $\mathsf {PA} \vdash (0 \ne 1)$,
Now, applying $(\forall \text I)$ to it, using $0$ as $\text {John}$, we conclude with: $\mathsf {PA} \vdash \forall x (x \ne 1)$.
Where is the mistake ?