Note carefully that you're doing an "inverse" substitution "$u = \sin x$", not an "ordinary (or $u$-)substitution" of the form $x = X(u)$. For your conclusion to follow from the change of variables theorem, you'd need
$$
\int_{0}^{2\pi} f(x)\, dx = \int_{0}^{0} g(u)\, du
$$
for some function $g$. Your argument proposes "solving" $f(x) = g(\sin x) \cos x$ for $g$, so that
$$
\int_{a}^{b} \underbrace{g\bigl(u(x)\bigr) u'(x)}_{f(x)}\, dx = \int_{u(a)}^{u(b)} g(u)\, du.
$$
But despite casual appearances, there is no such function $g$ because, as mercio says, your substitution isn't invertible (injective).
In symbols, you want to write
$$
g(u) = \frac{f(\arcsin u)}{\cos x} = \frac{f(x)}{\cos x}.
$$
However, $\arcsin(\sin x) \neq x$ if $|x| > \pi/2$, so this formal choice doesn't work.
Said another way, the function $\phi(x) = g(\sin x) \cos x$ satisfies the non-trivial symmetry $\phi(\frac{\pi}{2} - x) = -\phi(x)$ for all $x$ ($\phi$ is "odd with respect to $\frac{\pi}{2}$"), while $f$ need not.
Either way, if $f$ is given there is generally no $g$ such that $f(x) = g(\sin x) \cos x$, so your proof doesn't get off the ground.