I did this proof without using the hypothesis of $X$ compact. Is it correct?
If $(X,\tau)$ is compact and Hausdorff topological space, then $X$ is $T_4$.
Proof by contradiction
Let $x,y\in X$ with $x\neq y. $ Thus $\exists U,V\in\tau:x\in U, y\in V$ and $U\cap V=\emptyset...(*)$
Suppose there exist $F,G\subset X$ closed sets such that $\forall U',V'\in\tau:F\not\subset U',G\not\subset V'$ and $U'\cap V'\neq\emptyset$.
Now, as $\{x\}$ and $\{y\}$ are closed sets, take $F=x$ and $G=y$. This is a contradiction with $(*)$.
Hence $(X,\tau)$ is $T_4.$
No, it is not correct. You can't take $F=\{x\}$ and $G=\{y\}$. Being $T_4$ means that for any two closed sets $F$ and $G$ such that $F\cap G=\emptyset$, there are $A_F,A_G\in\tau$ such that $F\subset A_F$, that $G\subset A_G$ and that $A_F\cap A_G=\emptyset$.
And it could not be correct, because there are $T_2$ spaces which are not $T_4$.