This question is tagged solution-verification, which indicates that the asker is seeking a critique of their argument. As neither of the previous answers have addressed this, and as there is an important (and common!) error in the argument, I am answering in order to fill that gap.
The argument presented in the question is incorrect, though the spirit of the argument is good. The error is in the second line, where the asker writes:
- Cantor set is the union of closed intervals, and hence it is a closed set.
There are at least two errors in this statement:
The union of closed sets needn't be closed
It is not true that the union of closed sets is closed. For example, it is possible to write the open unit interval as the union of closed sets:
$$ (0,1) = \bigcup_{n=1}^{\infty} \left[ \frac{1}{n}, 1-\frac{1}{n} \right]. $$
For all integers $n$, the inequalities
$$ 0 < \frac{1}{n} \qquad\text{and}\qquad 1-\frac{1}{n} < 1, $$
which implies that neither $0$ nor $1$ is in any of the intervals in the union (therefore neither $0$ nor $1$ is in the union itself). However, for any real number $x \in (0,1)$, there exists some $n$ so large that
$$ \frac{1}{n} \le x \le 1 - \frac{1}{n}; $$
if $x < 1/2$, take $n$ to be larger than $1/x$. Otherwise, take $n$ to be larger than $1/((1/2)-x)$.
In short, an arbitrary union of closed sets needn't be closed. Indeed, the correct statements are:
- arbitrary unions and finite intersections of open sets are open
- finite unions and arbitrary intersections of closed sets are closed
The first statement will be useful, below.
The Cantor set is not a union of closed intervals
The Cantor set is not a union of intervals. In fact, the Cantor set doesn't contain any intervals. For contradiction, suppose that there is some interval $[a,b]$ contained in the Cantor set. While there are more elegant arguments, it might be simplest to observe that if $m,n\in\mathbb{Z}$ (with $0 < n < 3^m$, then the Cantor set cannot contain both of the points
$$\frac{n}{3^m}-\frac{1}{2\cdot 3^m}, \qquad\text{and}\qquad
\frac{n}{3^m}+\frac{1}{2\cdot 3^m}. \tag{1}$$
This is because the point $n/3^m$ is the endpoint of an interval that is removed in the $m$-th step of the construction. The interval removed is either
$$ \left( \frac{n-1}{3^m}, \frac{n}{3^m} \right)
\qquad\text{or}\qquad
\left( \frac{n}{3^m}, \frac{n+1}{3^m} \right). $$
As one of these intervals is removed in the construction of the Cantor set, at least one of the two points listed in (1) must be removed.
To show that the Cantor set contains no intervals, choose $m$ and $n$ such that both of the points given in (1) are in the interval $(a,b)$ (note that this shows not only that $[a,b]$ is not contained in the Cantor set, but also that $(a,b)$ is not contained in the Cantor set). This is possible, as the points are dense in $[0,1]$.
In short, the Cantor set contains no intervals, and cannot be written as the union of intervals.
Fixing the argument presented
Cyriac Antony gave a good argument, using the fact that arbitrary intersections of closed sets are closed. Summarizing that argument, take $C_0 = [0,1]$, and construct $C_{n+1}$ by removing the open middle third from each interval contained in $C_n$. Then each $C_n$ is closed and the Cantor set is given by
$$ \bigcap_{n=0}^{\infty} C_n, $$
which is a countable intersection of closed sets, therefore closed.
An alternative is to look at the sets which are removed: the core idea is that the Cantor set can be thought of as the complement of the sets which are removed at each stage of the construction.
For each $n$, define
$$ U_n = \bigcup_{j=1}^{\frac{3^n-1}{2}} \left(\frac{2j-1}{3^n}, \frac{2j}{3^n} \right). $$
Observe that $U_n$ is the set of all intervals of length $1/3^n$ where the left endpoint is an odd multiple of $1/3^n$. All of these intervals are removed in the construction of the Cantor set (there is redundancy here, but who cares?). Then define
$$ U = \bigcup_{n=1}^{\infty} U_n, $$
which is a countable union of open sets, and therefore open itself.
Observe that the Cantor set is precisely $[0,1] \setminus U$, and the complement of an open set is closed by definition (or, as this might make the point a little more clearly, the Cantor set is given by
$$ \mathbb{R} \setminus ( (-\infty,0) \cup U \cup (1, \infty), $$
which gives the Cantor set as the complement of an open set in $\mathbb{R}$, so that one doesn't need to muck about with subspace topologies at all).
In any event, the Cantor set is the complement of an open set, therefore closed.