Let’s say we have a compact space . A subset may not be itself compact, but there’s one useful case in which it will be. If is closed, then is compact.
Let’s take an open cover of . The sets are open subsets of , but they may not be open as subsets of . But by the definition of the subspace topology, each one must be the intersection of with an open subset of . Let’s just say that each is an open subset of to begin with.
Now, we have one more open set floating around. The complement of is open, since is closed! So between the collection and the extra set we’ve got an open cover of . By compactness of , this open cover has a finite subcover. We can throw out from the subcover if it’s in there, and we’re left with a finite open cover of , and so is compact.
In fact, if we restrict to Hausdorff spaces, must be closed to be compact. Indeed, we proved that if is compact and is Hausdorff then any point can be separated from by a neighborhood . Since there is such an open neighborhood, must be an interior point of . And since was arbitrary, every point of is an interior point, and so must be open.
Putting these two sides together, we can see that if is compact Hausdorff, then a subset is compact exactly when it’s closed.