We can generalize a) and b) by replacing with an injection and with a surjection. Clearly, an identity function is both an in injection and a surjection.

For a), assume that f is not an injection. Then it maps two distinct elements of A into one element of B. Can be an injection in this case?

Similarly, for b), if the second function is not a surjection, i.e., it does not cover all elements of B, then how a composition can be a surjection? Would you agree to live in the neighborhood where, even though the post office sorts the mail correctly, the letter carrier does not serve all houses?