For option A
$f^{-1}(f(A))=A \cup A^{\prime} \neq A$
Hence $A$ is wrong
For option B
$f(X)=Y \quad \Rightarrow \quad f$ is onto but it will not effect on mapping of function
Hence $B$ is wrong
For option A \& B other explaination can be given else if $Y$ is a singleton set then the function $f$ is constant function and hence is trivially onto (unless $X=\phi$ ). But in such a case, even if A consists of just one point, $f(A)$ is entire set $Y$ and so $^{-1}(f(A))$ is the entire set $X$, which could be much bigger than $A$. So $A$ and $B$ are wrong even if $f(X)=Y$
For option C
$f(X) \subset Y(\text { range } \neq \text { co-domain })$
$f(X)$ is a proper subset of $Y$ (so that $f$ is not onto), then for $B=Y$ option $C$ is wrong because $f^{-1}(Y)=X$ but $f\left(f^{-1}(Y)\right)=f(X) \neq Y$.
For option D
If $B=Y$, then $f\left(f^{-1}(Y)\right)$ is the range of the function $f$. If this is equal to $Y$, then function must be onto, thus $f(X)=Y$ is necessary condition
Hence $D$ is correct