Example 3 Let $A=\left\{a_{1}, a_{2}, a_{3}\right\}, B=\left\{b_{1}, b_{2}, b_{3}, b_{4}\right\}$.
(1) Write a function $f: A \rightarrow B$ such that $f$ is injective, and find the number of injective functions from $A$ to $B$;
(2) Write a function $f: A \rightarrow B$ such that $f$ is not injective, and find the number of such functions;
(3) Can a function from $A$ to $B$ be surjective?
(1) The mapping
$$
f: a_{1} \mapsto b_{1}, a_{2} \mapsto b_{2}, a_{3} \mapsto b_{3}
$$

is an injection from $A$ to $B$.
The number of such mappings is $\mathrm{P}_{4}^{3}=24$ (mappings).
(2) The mapping
$$
f: a_{1} \mapsto b_{1}, a_{2} \mapsto b_{1}, a_{3} \mapsto b_{1}
$$

is the one required.
The number of such mappings is $4^{3}-\mathrm{P}_{4}^{3}=40$ (mappings).
(3) The answer is negative.
Since each element in set $A$ corresponds exactly to one element in set $B$, and $|A|=$ $3,|B|=4$ (where $|A|$ denotes the number of elements in set $A$), there is at least one element in set $B$ that does not have a corresponding element in set $A$. Therefore, a surjection from $A$ to $B$ does not exist.

In general, if there is an injection from $A$ to $B$, then $|A| \leqslant|B|$; if there is a surjection from $A$ to $B$, then $|A| \geqslant|B|$.