As I said, functions are contravariant, so a function on B

Functions are contravariant on their domain, but covariant on their codomain.
Well, that's somewhat of an abuse of language. More accurately, "the set of functions from
X to
Y" is a functor contravariant in the variable
X and covariant in the variable
Y.
If I denote it by
Hom(X,Y), then:
For any function
f:Y>Z, I have
f_{*}:Hom(X,Y)>Hom(X,Z) given by
f_{*}(g) = f o g
For any function
f:W>X, I have
f^{*}:Hom(X,Y)>Hom(W,Y) given by
f^{*}(g) = g o f
For an example in the setting of manifolds, recall that for a manifold
M, we define a "curve on
M" to be a continuous function
[0,1]>M. This is a case where we fix the domain and vary the codomain, so curves get pushed around covariantly: given any continuous function
f:M>N and curve
c on
M, we have a pushforward curve
f_{*}(c) on
N, given by
f_{*}(c) = f o c.