In general topology the the definition of topology is the following:
Let X be a non empty set. A set $\tau$ of subsets of $X$ is said to be a topology on $X$ if
- $X \in \tau$ and $\emptyset \in \tau$
- The union of any (finite or infinite) number of sets in $\tau$ belongs to $\tau$
- The intersection of finitely many elements of $τ$ is an element of $τ$.
My question is, why do we define the topology on a set this way?
Why does the finite or infinite union of sets in $\tau$ belongs in $\tau$ but only the finite intersection of elements of $\tau$ belongs on $\tau$?
And why do we need to have that $X \in \tau$ and $\emptyset \in \tau$?
What is the motivation for this definition?
You ask a good question. I agree with the two answers above but wanted to add something. As a mathematician coming to these definitions they do seem arbitrary and perhaps lacking in justification. I found myself asking the same question about the axioms for a category. I think what happens is that mathematicians find lots of interesting examples of spaces (e.g. the metric spaces given above). They then develop a set of axioms for a new thing (a topological space). The axioms are chosen so they are strong enough to prove many interesting theorems but weak enough to admit loads of interesting and varied examples as topological space (for example the particular point topology https://en.wikipedia.org/wiki/Particular_point_topology in which a single point set is compact but its closure is not compact (if the space is infinite) - crazy!). Note that the axioms of topology evolved (some people included a separation axiom https://en.wikipedia.org/wiki/History_of_the_separation_axioms). I think groups, categories, rings and fields are all a bit like this. This is quite different from natural numbers, real numbers and geometry which all seem to be understood by us intuitively. A difficult question is whether ZF Set Theory is of the first type (axioms chosen by humans) or the second (things that 'really' exist or at least are consistent with some intuition, real or conceptual).