Given a map $f:X\to Y$ and a subset $B$ of $Y$, recall that $f^{-1}(B)$ is defined as the set of all $x\in X$ such that $f(x)\in B$.
Now if $y\in f(f^{-1}(B))$, there exists $x\in f^{-1}(B)$ such that $y=f(x)$, but this implies that $y\in B$.
We have proved so far (without any special assumption) that $f(f^{-1}(B))\subset B$.
Equality is not true in general, as we can see with $f:\mathbb{R}\to\mathbb{R},\,x\mapsto x^2$ and $B=[-1,1]$ :
in this case : $f(f^{-1}(B))=f([-1,1])=[0,1]\neq B$
Now suppose $f$ is surjective and consider $y\in B$. There exists $x\in X$ such that $y=f(x)$ which implies $x\in f^{-1}(B)$ and therefore $y\in f(f^{-1}(B))$.
Finally, if $f$ is surjective then for all $B\subset Y$, we have : $f(f^{-1}(B))=B$.
Remark
It should be added that the converse is true : if $f:X\to Y$ is such that $\forall B\subset Y,\,f(f^{-1}(B))=B$, then $f$ is surjective.
Proof : considering $y\in Y$ an choosing $B=\{y\}$, we get : $f(f^{-1}(\{y\}))=\{y\}$. Hence $f^{-1}(\{y\})\neq\emptyset$.