How are Infinite sets compact? A set is compact iff every open cover of the set has a finite subcover. Also, every set can be expressed as a union of singleton sets(which are open). So my question is how can a set containing infinite elements be compact ($[1,2]$ for an instance) considering the open cover consisting of singleton sets??
 A: 
the open cover consisting of singleton sets

An open cover isn't just any old collection of sets which cover the given space - it's a collection of open sets which cover the given space. So when you say "the open cover consisting of singleton sets," you're assuming every singleton set is open.
This isn't true in general - e.g. in $\mathbb{R}$ with the usual topology, singletons are closed but not open. (In fact, "every singleton is open" is a very strong property - if $(X,\tau)$ is a space where every singleton is open, then every subset of $X$ is open in the sense of $\tau$.)

At this point it's worth being careful about what a topological space is, exactly. A topological space is a pair $(X,\tau)$ where


*

*$X$ is some set (like $\mathbb{R}$), and

*$\tau$ is a collection of subsets of $X$ (the "open sets") with a few properties ($\tau$ is closed under finite intersections, arbitrary unions, and we need $X,\emptyset\in\tau$).
Often when $\tau$ is obvious from context, we just talk about $X$ on its own - e.g. when we say "$(0, 1)$ is an open subset of $\mathbb{R}$" - but this is technically wrong! Instead, we should say something like "$(0,1)$ is an open subset of $\mathbb{R}$ with the Euclidean topology."
