Say I have a function $f$. Then, if I understand correctly, $f$ can be regarded as a morphism in a suitably chosen category which has the domain of $f$ and the range of $f$ as objects.

So, the other direction. Say I have a morphism $f$ in some category from one object $A$ to another object $B$. Can I not regard $f$ as a function whose domain is $\{A\}$ and range $\{B\}$?

I'm interested in looking for contexts in which the latter move is not appropriate for some reason.