Why surjectivity is defined by "for every $y$,there exist $x$ such that$ f(x)=y$" instead of "$x_1=x_2\Rightarrow f(x_1)=f(x_2)$" I think injective and surjective is a dual concept.
Injective: $f(x_1)=f(x_2) \Rightarrow x_1=x_2$
But the definition of surjective is so different.
It's "for every $y$,there exist $x$ such that $f(x)=y$".
so why we define surjective by "for every $y$,there exist $x$ such that $f(x)=y$" instead of "$x_1=x_2 \Rightarrow f(x_1)=f(x_2)$"
 A: If $x=y$ then $f(x)=f(y)$ is a basic property of a function.  It is true for all functions whether injective, surjective or neither.
A: Let $X$ be the domain of the function $f$ and $Y$ be its codomain.
Injective function: A function for which to every $y$ in the codomain it exist MAXIMUM one $x \in X$ such that $f(x) = y$ 
Surjective function: A function for which to every $y$ in its codomain it exist AT LEAST one $x \in X$ such that $f(x) = y$
Bijectve function: A function that is both injective and surjective, in other words, to every $y$ in its codomain it exist precisely ONE $x \in X$ such that $f(x) = y$
I hope this helps.
A: You are correct that the concepts of injectivity and surjectivity are somehow dual. However, you are missing the "big picture" by only thinking on the level of elements.
We may think of injections and surjections in terms of left invertible and right invertible functions. 
Definition 1. A function $f:A\to B$ of nonempty sets is injective if there exists a function $g:B\to A$ such that $g\circ f=\operatorname{id}_A$.
Definition 2. A function $f:A\to B$ of nonempty sets is surjective if there exists a function $g:B\to A$ such that $f\circ g=\operatorname{id}_B$.
By comparing these two definitions, we see that injectivity and surjectivity are (in some sense) dual. Injectivity means "left invertible" while surjectivity means "right invertible".
If you want to get fancy, you could rigorously formulate all of this using the language of category theory. Here, the statement is that a morphism $f$ is injective in $\mathsf{Set}$ if and only if it is surjective in $\mathsf{Set}^{\operatorname{op}}$. More generally, a morphism $f$ in a category $\mathsf{C}$ is monic if and only if $f$ is epic in $\mathsf{C}^{\operatorname{op}}$.
A: *

*Def.: let be $f:A \to B$ a function, $f$ is injective if $$\forall x,y \in A(f(x)=f(y)\to x=y)$$ You can prove$$f \mbox{ is injective} \Leftrightarrow  \forall x,y \in A(x \neq y \to f(x)   
   \neq f(y))$$

*Def.: let be $f:A \to B$ a function, $f$ is surjective if $$f(A)=B$$ You can
prove $$f \mbox{ is surjective} \Leftrightarrow \forall y \in B(\exists x \in A(f(x)=y))$$

A: You don't need to know anything about functions to see the problem.
As long as $f(x)$ is defined and it doesn't matter what it is then
$$x=y\Longrightarrow f(x)=f(y)$$
simply by the rules of logic, $x=y$ lets you replace $x$ with $y$ anywhere you want.
