  Let $A_1, A_2\in \mathbb C(z)$ be rational functions of degree at least two
that are neither Latt\`es maps nor conjugate to $z^{\pm n}$ or $\pm T_n.$ We
describe invariant, periodic, and preperiodic algebraic curves for
endomorphisms of $(\mathbb P^1(\mathbb C))^2$ of the form $(z_1,z_2)\rightarrow
(A_1(z_1),A_2(z_2)).$ In particular, we show that if $A\in \mathbb C(z)$ is not
a "generalized Latt\`es map", then any $(A,A)$-invariant curve has genus zero
and can be parametrized by rational functions commuting with $A$. As an
application, for $A$ defined over a subfield $K$ of $ \mathbb C$ we give a
criterion for a point of $(\mathbb P^1(K))^2$ to have a Zariski dense $(A,
A)$-orbit in terms of canonical heights, and deduce from this criterion a
version of a conjecture of Zhang on the existence of rational points with
Zariski dense forward orbits. We also prove a result about functional
decompositions of iterates of rational functions, which implies in particular
that there exist at most finitely many $(A_1, A_2)$-invariant curves of any
given bi-degree $(d_1,d_2).$
