Let $A=f(B)\subset X$ where $B=\{{(x,y) \in \mathbb{R}^2 \mid 1 \leq x^2+y^2 \leq 2 \}} $, $X$ is arbitrary topological space and $f: \mathbb{R}^2 \to X$ is an arbitrary continuous map. Then $A$ is compact and connected but not closed and open.
I have a doubt that if $A$ is compact then it is closed, but the answer says only compact and connected. Please help me as I have learnt topology several years back and I am not that strong in it now.
$A$ can be open and closed: take $X=\{0\}$ with any topology you like. Then we have that $f$ is constant, so continuous, and $A=f(B)=\{0\}=X$ is open and closed as it is the space itself.
Now assuming one of the equivalent statements: $f$ is injective or $f^{-1}(A)=B$:
Suppose that $A$ is closed and open, then due to the continuity of $f$ we would have that $B=f^{-1}(A)$ is closed and open, but obviously $B$ is not open is $\mathbb{R}^2$ (take for example any open ball around $(2,0)$, this will always have a non-empty intersection with $B^c$), so we have a contradiction.
Remarks:
OP probably already knew it, but the image of a compact set under continuous function $f$ is also compact. Exactly the same holds if you replace the words compact by the words connected.
Taken from one of my comments: Here is the proof of compact implies closed in Hausdorff spaces and here is a counterexample for general topological spaces.
Special thanks to @AndreasBlass for noting that injectivity is needed to make my proof hold.