I've read through a few of the other posts on the site, but I still don't quite understand.
Suppose $f : A \to B$, for $A = \{a, b, c\}$ and $B = \{1, 2, 3, 4\}$, and suppose that we define the function $f(x)$, for some $x \in A$, as:
$f(a) = 1$
$f(b) = 2$
$f(c) = 3$
That is, the element $4$ in the codomain remains unmapped/unassigned to any element in the codomain. While the function is one-to-one, it is not surjective, and thereby is not bijective.
The inverse, if we were to write one up, would look like so:
$f(1) = a$
$f(2) = b$
$f(3) = c$
$f(4) = undefined$
Now, what I don't understand is why this is a problem. Why did the original function have to be surjective? Consider the familiar function $f : R \to R$ such that $f(x) = \frac{1}{x}$. This function, while one-to-one, is not onto, just as with my example above. However, we can still find an inverse:
$y = f(x) = \frac{1}{x}$
$xy = 1$
$x = \frac{1}{y}$
$y = \frac{1}{x}$
$f^{-1}(x) = \frac{1}{x}$
Keep in mind three things about the mathematical concept of a function and its inverse
In your example of $f : \{a,b,c\} \to \{1,2,3,4\}$, in your attempt to write a formula for an inverse function $f^{-1} : \{1,2,3,4\} \to \{a,b,c\}$ you write $f^{-1}(4) = undefined$. But "undefined" is not allowed for a function whose range is the set $\{a,b,c\}$, $f^{-1}(4)$ must be an element of the set $\{a,b,c\}$.
In your example of $f : R \to R$ given by $f(x)=\frac{1}{x}$, notice that $f(0)$ is undefined, so this example also violates the requirements for a function.
Now, if you had instead written $f : R - \{0\} \to R - \{0\}$ given by $f(x) = \frac{1}{x}$, that would indeed have been a bijection. And it would have an inverse. In fact, $f$ is its own inverse: $f = f^{-1}$.