It seems that you neglect the fact that the expected value symbol represents different things depending on what it operates on.
Identically distributed r.v.'s means that they are characterized by the same distribution and the same support for this distribution, so
$$E(X^2) = \int_{S}x^2f(x)dx = \int_{S}y^2f(y)dx = E(Y^2)$$
But $E(XY)$ is a double integral with respect to the joint distribution (see also this post):
$$E(XY)=\int_{S}\int_{S}xyf(x,y)dxdy$$
Even ignoring the presence of the density functions, it should be obvious that in general
$$\int_{S}x^2dx \neq \int_{S}\int_{S}xydxdy$$
even if the two variables run over the same interval.
The argument "if they are identically distributed, then, when we use their moments we can treat them as the same random variable" holds only whenever moments of the marginal distributions of the two r.v.'s under consideration are involved. In the expression $E(XY)$ you don't use the expectation of $X$ or of $Y$ - you use the expectation of $XY$ which is a third random variable.