In my book they define the compact as follows :
$G$ is compact if for every covering of $G$ by open, we can pick out a finite number of the sets that still covers G.
But a union of open is an open.
Thus, if G is compact, there is a finite union of open that covers G. Thus G is open.
But in $\mathbb{R}^n$ compact => closed so I don't get.
PS : I am beginner in topology so I would like a simple explanation using definitions =) (and not a magic theorem that I don't know for example).
Seems like this was cleared up in the comments while I was writing my answer, but here it is anyways (it might still be useful to OP on account of the precise definitions given below).
Note, in particular, that a set $G$ being compact does not imply that there exists a finite open cover $\{G_{n}\}_{n=1}^N$ of $G$ whose union is exactly equal to $G$ (i.e., $\cup_n G_n = G$). This is the source of confusion.