Why is the relation "$f=g $ almost everywhere" transitive? In Rudin's Real and Complex Analysis, it says on pg 27 that
If $\mu$ be a measure, define $f\sim g$ iff $\mu(\{x|f(x)≠g(x)\})=0$, where $f,g$ are measurable functions from $X$ to a topological space $Y$.
Then, $f\sim g$ is an equivalence relation.
But, I do not see why $f\sim g$ is transitive. 
If I assume $f\sim g$ and $g\sim h$, then by definition, $\{x|f(x)≠g(x)\}$ and $\{x|g(x)≠h(x)\}$ are measurable sets with measure zero.
But then, how do I know that the set $\{x|f(x)≠h(x)\} \subset \{x|f(x)≠g(x)\} \cup  \{x|g(x)≠h(x)\} $ is measurable?
Here $Y$ is a topological space, not necessarily $R$ or extended reals. 
 A: Rudin's has this definition: property $P$ holds a.e. on $E$ iff there is a null set $N \subset E$ such that $P$ holds at every point of $E - N$.  It does not say $\{x\;|\; P\text{ holds at }x\}$ is measurable.  With this notion, the transitivity is OK.
But then he goes and ruins it by saying $f=g$ a.e. means $\mu(\{x\;|\;f(x) \ne g(x)\})=0$, implicitly requiring $\{x\;|\;f(x)\ne g(x)\}$ to be measurable.  As you note, in case $Y$ is a weird topological space where the diagonal is not closed in $Y \times Y$, we cannot conclude that $\{x\;|\;f(x)\ne g(x)\}$ is measurable for measurable functions $f,g$.
Of course Rudin applies the notion "$f=g$ a.e." only in cases when $Y$ is metrizable, where there is no problem.
A: So here is our example.  As noted in the other answers, we need $\mathfrak M$ not complete, and $Y$ not metrizable.
Let $X = \mathbb R$, $\mathfrak M =$ Borel sets, $\mu =$ Lebesgue measure.
Let $Y = \mathbb R$, indiscrete topology.  The only open sets are $\varnothing, \mathbb R$.  
Because $Y$ is indiscrete, every function $f \;:\; X \to Y$ is measurable.
Let $N \subseteq X$ be the Cantor set, a Borel null set;
and let $K \subseteq N$ be non-measurable.  There are $2^{\mathfrak c}$ subsets of $N$, but only $\mathfrak c$ Borel sets, so certainly there is
such a set $K$.  Now define
$$
f(x) = \begin{cases}0,\qquad x \in K
\\0,\qquad x \in N - K
\\0,\qquad x \in \mathbb R - N\end{cases}
\\
g(x) = \begin{cases}1,\qquad x \in K
\\1,\qquad x \in N - K
\\0,\qquad x \in \mathbb R - N\end{cases}
\\
h(x) = \begin{cases}0,\qquad x \in K
\\2,\qquad x \in N - K
\\0,\qquad x \in \mathbb R - N\end{cases}
$$
Then:
$f=g$ a.e. since $\{x \mid f(x) \ne g(x)\} = N$ is a measurable null set.
$g=h$ a.e. since $\{x \mid g(x) \ne h(x)\} = N$ is a measurable null set.
But not $f=h$ a.e., since $\{x \mid f(x) \ne h(x)\} = K$ is not measurable.
A: UPDATED ANSWER
The following argument works only if the $\sigma$-algebra on $X$ is complete.:
If $x$ satisfies $f(x) \neq h(x)$, then it satisfies exactly one of the following three cases: 
a) $f(x) \neq g(x)$ and $g(x) = h(x)$
b) $f(x) = g(x)$ and $g(x) \neq h(x)$
c) $f(x) \neq g(x)$ and $g(x) \neq h(x)$
Then if we let $$A = \{x \mid f(x) \neq g(x) \} \cap \{x \mid g(x) = h(x) \}$$ $$B = \{x \mid f(x) = g(x) \} \cap \{x \mid g(x) \neq h(x) \}$$ $$C = \{x \mid f(x) \neq g(x) \} \cap \{x \mid g(x) \neq h(x) \}$$ we have $\{x \mid f(x) \neq h(x) \} \subseteq A \cup B \cup C$.  Since $A, B,$ and $C$ are sets of measure $0$, their union is also a set of measure $0$, and thus so is $\{x \mid f(x) \neq h(x)\}$ (since the $\sigma$-algebra is complete). 
