Is there a category-theoretic explanation for this analogy between $\mathbf{Set}$ and $\mathbf{Vect}_k$? You can tell whether there exists an injective, surjective, or bijective map $A\to B$ by comparing the cardinalities of $A$ and $B$. Similarly, you can tell whether there exists an injective, surjective, or bijective linear map $U\to V$ by comparing the dimensions of $U$ and $V$ (i.e., the cardinalities of their Hamel bases).
Is there a category-theoretic explanation for this analogy? I'm inclined to consider the functor $\mathbf{Set}\to\mathbf{Vect}_k$ given by formal linear combinations on objects and linear extensions on arrows, but I'm not sure where to go from there.
 A: I am not aware of one. The basic issue for trying to find an abstract categorical explanation is that this isn't even close to true if you replace the field $k$ by a more general ring, so you have to be using some fact specific to fields (namely that every module is free (assuming the axiom of choice)).
Generally, in any category $C$ consider the preorder on the objects of $C$ given by $x \le y$ iff there is a monomorphism from $x$ to $y$ (considering epimorphisms produces a second, analogous preorder). In $\text{Set}$ this preorder has the following special properties:

*

*After quotienting by isomorphisms, it is a total order (this requires the axiom of choice).

*If $x \le y$ and $y \le x$ then $x$ and $y$ are isomorphic (this is the Cantor-Schroeder-Bernstein theorem).

Both of these facts are quite special and specific to $\text{Set}$, and almost never hold in almost any other categories (e.g. they both fail quite badly in $\text{Top}$ or $\text{Grp}$). When they do hold (e.g. in $\text{Vect}$) they hold for specific reasons, not general categorical ones. You can see, for example, this math.SE question for a discussion of when the Cantor-Schroeder-Bernstein theorem holds in categories other than $\text{Set}$.
A: I think this is better understood in terms of "invariants" and "complete invariants".
Informally speaking, an "invariant" for a category $\mathscr{C}$ is a function $f$ from $\mathrm{Ob}(\mathscr{C})$ to some specified set or class $X$, with the property that if $A\cong B$ in $\mathscr{C}$ then $f(A)=f(B)$ in $X$. That is, equality of $f$ is a necessary condition for $A$ and $B$ to be isomorphic.
Usually, you want the computation of $f(A)$ and $f(B)$ to be much simpler than trying to determine whether any of the elements of $\mathcal{C}(A,B)$ are invertible. Usually there is a trade-off: the easier it is to compute $f$, the more information you should lose in the process, so that the condition $f(A)=f(B)$ tends to be weaker; that is, the equivalence relation on $\mathrm{Ob}(\mathscr{C})$ is coarser.  (You can replace $X$ with a category, and then require $f(A)\cong f(B)$. In that situation, you may even have that $f$ is a functor, which may facilitate the computation of $f$.)
For example, the fundamental group of a topological space is an invariant: homeomorphic spaces will necessarily have (isomorphic) fundamental groups; but two spaces with isomorphic fundamental groups need not be homeomorphic. Likewise, the cardinality of a finite group is an invariant, but groups with the same cardinality need not be isomorphic. Another example is the Alexander polynomial of a knot (or the Jones polynomial of a knot).
Ideally, you want a "complete invariant". A complete invariant is an invariant in which the implication goes both ways: that is, $A\cong B$ if and only if $f(A)=f(B)$; or in the more general situation, if $f(A)\cong f(B)$.
In $\mathsf{Set}$, the cardinality is a complete invariant: two sets are isomorphic if and only if they have the same cardinality. The amazing thing in $\mathsf{Vec}_F$, the category of vector spaces over the field $F$, is that "dimension" is likewise a complete invariant, so that two vector spaces over $F$ are isomorphic if and only if they have the same dimension. But this is no longer true in more general categories, such as the category of all vector spaces (where vector spaces over different fields are not even "connected"), or to modules over rings.
