I don't think this is special about the canonical bundle. All you need is a line bundle with a section which is contractible inside the total space of the line bundle.
Another way to generate such examples is the following: Take a smooth projective variety $Y$ (embedded in a projective space) and let $X$ be the cone over Y. Blowing up the vertex of $X$ is a resolution of the singularity of $Y$ and the blow up, say $B$, is naturally the total space of a line bundle on $Y$.
You might ask what line bundle you get this way.
Well, we know that if we blow up a point in a smooth variety, then the
exceptional divisor is a projective space and its normal bundle is $\mathscr O(-1)$. This means that when you blow up a cone, the exceptional divisor is isomorphic the original smooth variety which is naturally embedded in the exceptional divisor of the blow up of the affine space which is the cone over the original projective space. So the normal bundle of $Y$ in $B$ is the $\mathscr O(-1)$ corresponding to the original embedding of $Y$ you started with.
The last question one needs to answer is: What is the normal bundle of a section in the total space of a line bundle? The "obvious" answer is that it is that line bundle. Why? Well, the tangent bundle of the section is clearly the restriction of the pull-back of the tangent bundle from $Y$ and so the normal bundle has to be the restriction of the relative tangent bundle. Given that it is a line bundle the relative tangent bundle will be just that line bundle.
So where are we now. Let's say that you have a line bundle $\mathscr L$ on your favorite smooth projective variety whose inverse (dual) is very ample. Using the global sections of this inverse, embed $Y$ into a projective space, take the cone over it and let that be $X$. Blowing up $X$ at its vertex gives you the total space of the line bundle $\mathscr L$ over $Y$.
In case you wonder how the total space of an anti-ample line bundle has a section, then recall that the sheaf of sections of the total space of a line bundle is the dual of the line bundle.
Finally, this shows that this works for the canonical bundle of any Fano variety. Your example appears as the resolution of the cone over the $n+1$-uple embedding of $\mathbb P^n$ which happens to be given by the global sections of the dual of the canonical bundle, but the fact that it is the canonical bundle has not much to do with this.
The rest is a response to the additional question in the comments below.
Remark.
The following statement is somewhat related to the above problem:
Lemma
Let $Z\to \mathbb P^n$ be a $\mathbb P^1$-bundle with a section $E\subseteq Z$ and assume that there exists a proper birational morphism $\alpha:Z\to X$ such that $\alpha$ contract $E$, i.e., $\alpha(E)$ is a point and $\alpha|_{Z\setminus E}$ is an isomorphism. If $X$ is normal and factorial (i.e., every Weil divisor is Cartier), then $X\simeq \mathbb P^n$.
This is an intermediate statement in Mori's proof of Hartshorne's conjecture, see Kollár's book on rational curves.
So, this implies that if $Y=\mathbb P^n$, and $X$ is not the affine space $\mathbb A^{n+1}$ (which happens if $Y$ is embedded as a linear subspace), then $X$ cannot be factorial. The easiest examples of non-factorial singularities are quotients by finite groups. Furthermore, if $Y=\mathbb P^n$ or more generally such that $\mathrm{Pic} Y\simeq \mathbb Z$, then the local class group of the singularity of $X$ is a finite cyclic group (the point is to realize that it is torsion and generated by a single element). This implies that there is a finite (non-flat!) cover of $X$ which is factorial. One could argue that then it is not surprising that we would find finite quotient singularities among these.