Gelfand duality for the connection between $K$ and $C(K)$ Suppose $K_1,K_2$ are compact topological spaces, let $\pi$ be a homomorphism: $C(K_2)\rightarrow C(K_1)$, then we can find a continuous map $\tau: K_1\rightarrow K_2$, s.t $\pi(f)=f\circ\tau$. Likewise, if we have $\tau: K_1\rightarrow K_2$, then the map $\pi: \pi(f)=f\circ\tau$ is a homomorphism. This is called Gelfand duality. Thus it is easy to prove that $\tau$ is homeomorphism iff $\pi$ is isometrically isomorphism. 
I read some notes about these stuff. It says that by that every topological property in $K$ can be reflected by algebraic property in $C(K)$,e.x. $K$ is connected iff $C(K)$ contains no idempotents. But from Gelfand duality, I could only see the connection between $C(K_1)$ and $C(K_2)$ reflects the connection between $K_1$ and $K_2$

Gelfand duality tells you, that you have a contravariant functor between the category of compact topological spaces and the category of commutative $C^*$-algebras (which is even an equivalence). 
The part you stated is only the contravariance, i.e. that your functor reverses the direction of the morphisms (continuous maps for spaces, algebra homomorphisms for algebras). 
For the connection between e.g. connectedness of $K$ and no idempotents of $C(K)$ you have to dig a little deeper and learn how to find the space if you have the algebra at hand (via defining a topology on the spectrum of the algebra).
See https://ncatlab.org/nlab/show/Gelfand+duality and references therein for details. Note that understanding this math will probably take some time, as you have to understand basics of category theory and need some profound knowledge of $C^*$-algebras and topological spaces. 
