For reference, definition of inverse image is taken to be the following: Let $f:X\rightarrow Y$ be a function. If $j$ be a part (subset) of $Y$, then a part $i$ of $X$ is the inverse image of $j$ along $f$ if following is satisfied for any general element $x:T\rightarrow X$ $$x\in i\Leftrightarrow fx\in j$$
[From'Sets for mathematics' by F.W. Lawvere and R. Rosebrugh]
In the same book the following property of inverse image is called contravariant functoriality property: If $j$ is the inverse image (upto equivalence of parts) of $k$ along $g$ and $i$ is the inverse image of $j$ along $f$, then $i$ is the inverse image of $k$ along $gf$.
Question: I do see that there is a contravariantness to the property as we start with a part of the codomain of the last function and work in the direction opposite to the direction of functions. But I don't see how this contravariantness is functorial.
I did try to see if the functor induced by $f$ from the category of parts of $Y$ to the category of parts $X$ has to be contravariant, but it turns out to be not necessary as $j\subseteq j'\Rightarrow f^{-1}(j)\subseteq f^{-1}(j')$.
(Porting my comment as an answer)
The action of taking preimages is (contravariantly) functorial in that it defines a contravariant functor $\def\Set{\mathbf{Set}}\Set\to\Set$ given by sending a set $X$ to its power set $2^X$, and sending a function $f:X\to Y$ to its preimage function $f^{-1}:2^Y\to2^X$.
Functoriality here means that if $f:X\to Y$ and $g:Y\to Z$, then $(g\circ f)^{-1} = f^{-1}\circ g^{-1}$, which might be a familiar identity.
What's also interesting to note is that this functor is also what you use to establish a (covariant) equivalence of categories between $\Set^{\mathrm{op}}$ and the category $\mathbf{CABA}$ of complete atomic boolean algebras.