You need to know that $f$ is a bijection. Assuming this is the case throughout, the equivalence does hold.
Suppose that $f$ is a homeomorphism. Suppose $f^{-1}[B]$ is open in $X$. As $f$ is a bijection we know that $B = f[f^{-1}[B]]$ and $f$ is an open map as well, so $B$ is open as the image under $f$ of an open set. If $B$ is open in $Y$, continuity of $f$ will already give that $f^{-1}[B]$ is open in $X$. So the equivalence holds, assuming $f$ is a homeomorphism.
Suppose we know that for all $B \subseteq Y$, $B$ open iff $f^{-1}[B]$ open, and we already know $f$ is a bijection (!), then we conclude that $f$ is a homeomorphism: $f$ is continuous because of the implication $B$ open then $f^{-1}[B]$ open, and $f$ is open because if $O$ is open in $X$, we can write (by being a bijection!) as $f^{-1}[f[O]]$, so applying the implication the other side: we know for $B = f[O]$ that $f^{-1}[B] = O$ is open, so $B = f[O]$ is open.
We need the bijection condition because any map between discrete spaces would be a homeomorphism, while only bijections can be homeomorphisms in the first place.
A map $f$ such that for all $B \subseteq Y$: $B$ open iff $f^{-1}[B]$ open, is called a quotient map.
So the statement I just proved is just: a bijective map is a homeomorphism iff it is a quotient map. But there are many non-bijective quotient maps.