Why? How do we know how these definitions are related?
Fix a set $S$
Consider an equivalence relation $\sim$ on $S$. Consider the equivalence classes $[a]=\{ x \in S : x \sim a \}$. By definition these are subsets of $S$. Their union is $S$ because by reflexivity $a\in[a]$ for every $a\in S$. Finally, they are disjoint because if $x \in [a]$ and $x \in [b]$ then $x \sim a$ and so $a \sim x$, by symmetry. But then $a \sim b$ by transitivity and so $a\in [b]$. Every $y \in [a]$ is also in $[b]$ again by transitivity. This means that $[a]\subseteq [b]$. Swapping $a$ and $b$, we conclude $[a]=[b]$. All this means that the equivalence classes form a partition of $S$.
Conversely, given a partition of $S$ in subsets $C_\lambda$, define an equivalence relation in $S$ by $a\sim b$ iff there is a $\lambda$ such that $a$ and $b$ are both in $C_\lambda$. Since the $C_\lambda$ cover $S$, every $a\in S$ is in one of those and so $\sim$ is reflexive. By definition, $\sim$ is symmetric. Since the $C_\lambda$ are disjoint, $\sim$ is transitive.
Note: Every partition of a set determines an equivalence relation on that set, and for every equivalence relation, the equivalence classes corresponding to that relation form a partition of the set.
To try to put into words the relationship between a partition on a set, and the equivalence relation determined by that partition (or vice versa):
Think of simple examples of an equivalence relation on a set X, and its corresponding equivalence classes (say, $\equiv \pmod 2$ on the set of integers). What are the corresponding equivalence classes? There are two: the set of even integers, and the set of odd integers.
Evens: $E = \{x \in \mathbb{Z}\mid x\equiv 0 \pmod{2}\}$, Odds: $O = \{y \in \mathbb{Z} \mid x\equiv 1\pmod{2}\}$
Is the union of the two equivalence classes equal to the set of integers? (yes). That is, $E \cup O = \mathbb{Z}$.
Is any integer in more than one of those classes? (no). That is, $E\cap O = \varnothing$.
So we have two equivalence classes whose union is the set of integers, and whose intersection is empty. Hence, we have a partition on $\mathbb{Z}$ into two sets: the set of all even integers, and the set of all odd integers.
By definition every element in a given equivalence class is related to every other element in that class, and not to any element belonging to a different equivalence class. In the example I give above, all even numbers are related (they are even i.e., $\equiv 0 \pmod{2}$), all odd numbers are related (they are all odd, i.e., $\equiv 1 \pmod{2}$), but no integer is both even and odd.
The collection of all the equivalence classes is a partition of $X$. Every $x \in X$ belongs to one and only one equivalence class.
For example, the second definition is telling you that the union of all the equivalence classes of $X$ IS $X$ (put differently, every element of X is contained in an equivalence class) and that if any two equivalence classes are not equal, then they are disjoint: their intersection is the empty set. So every element of $X$ is in one and only one equivalence class.