The kind of thing you are talking about is called 'Null Quantification'.
Here are the relevant equivalence principles:
Null Quantification
With $x$ a variable, and $\varphi$ a formula that does not contain $x$ as a free variable, we have:
$\exists x \varphi \Leftrightarrow \varphi$
$\forall x \varphi \Leftrightarrow \varphi$
The equivalences hold because for any interpretation, the exact same objects that satisfy the left side satisfy the right side ... Exactly because the quantifier has no bearing on this.
To give one particular case of this to make this even more intuitive: suppose $\varphi = P$ for some statement $P$. Then $\exists x P$ is true iff there is some object in the domain such that $P$ is true ... which of course is true just when$P$ is true.
So, in your case, we have that $\exists y P(x) \Leftrightarrow P(x)$, and therefore $\forall x \exists y P(x) \Leftrightarrow \forall x P(x)$. Same for the other one.