This follows from the more general main theorem of connectedness (See for example here.), which can be seen as a generalization of the intermediate value theorem: If $f\colon X_1\rightarrow X_2$ is continuous and $X_1$ is (path)connected, then $f(X_1)\subseteq X_2$ is (path)connected.
If $f$ is a bijection, then you have $f(X_1)=X_2$ and if it is a homeomorphism, then $f^{-1}$ is also continuous and you can apply the theorem to it for the backwards direction.
Proof (for connectedness): Let $U,V\subset f(X_1)$ be open and disjoint sets with $U\cup V=f(X_1)$, then $f^{-1}(U),f^{-1}(V)\subset X_1$ are also open (since $f$ is continuous) and disjoint (as the preimage commutes with intersections: $f^{-1}(U)\cap f^{-1}(V)=f^{-1}(U\cap V)=f^{-1}(\emptyset)=\emptyset$) and we have (as the preimage also commutes with unions):
$$f^{-1}(U)\cup f^{-1}(V)
=f^{-1}(U\cup V)
=f^{-1}(f(X_1))=X_1.$$
Since $X_1$ is connected, we have $f^{-1}(U)=\emptyset$ (without loss of generality) and therefore $U=\emptyset$. $\square$
The problem with your proof is, that you want to show, that $X_2$ is connected, but you start with subsets of $X_1$ and transfer them to $X_2$ using $f$. The idea is right, but has to be done the exact other way around as not every subset of $X_2$ is the image of a subset of $X_1$. Also, $f$ in general does not commute with intersections and unions (you only get inclusions, which can be proper), while $f^{-1}$ does.