This really boils down to the long-standing question of "what is the best intuitive understanding of the dot product" which, admittedly, is no dobut a mystery to many as it very often comes up.
What I would say with regard to that question - and which thus also answers the one in your title - is that the dot product is a "mathematically nicefied" version of the projection operation: namely, the intuition is that $\mathbf{a} \cdot \hat{\mathbf{u}}$, for a unit vector $\hat{\mathbf{u}}$, is indeed that it is the component of $\mathbf{a}$ in the direction of $\hat{\mathbf{u}}$, and we could start the construction of the dot product from there.
The question, of course, arises as to what to do if $\mathbf{u}$ is not a unit vector. One option would be just to say that it doesn't matter: just give the projection (component) in the direction anyways. However, that leads to some problems. For one, let's consider commutativity. Ideally, we'd like it if our product were commutative:
$$\mathbf{a} \cdot \hat{\mathbf{u}} = \hat{\mathbf{u}} \cdot \mathbf{a}$$
however, if we are going down the line of description I just gave and just say it gives the projection to the second operand as a pure directional indicator, then we have an asymmetric, non-commutative operation.
Yet fortunately, it turns out that, very nicely, these problems go away if we decide that
$$\mathbf{a} \cdot \mathbf{u}$$
when $\mathbf{u}$ is not a unit vector, is to be the projection scaled by the length of the vector of projection, here, $\mathbf{u}$. Given that the projection already scales by the length of the vector being projected, effectively, this causes both vectors to be treated "on equal footing", so to speak, and the operation now commutes. Moreover, it becomes even bilinear, which is even better, and thus makes it a tensor (perhaps even the canonical example!), which allows all sorts of generalizations in more sophisticated mathematical usage, including the ability to define Riemannian manifolds and talk about curved, non-Euclidean spaces, and also the ability to provide infinite-dimensional spaces with useful topological structures permitting things like infinite linear combinations, as we get when we go down the inner product space sequence.
In short, the dot product represents projection onto a unit vector because at that point, the scaling coefficient we introduce to make it mathematically "nice" and "even-handed" equals $1$ when the vector of projection is such.
Best Answer
Note that with $a$ and $b$ two sides of a triangle and $\theta$ the angle between them, the third side is $b-a$ and (cosine rule) $$|b-a|^2=|a|^2+|b|^2-2|a||b|\cos \theta$$ so that $$2|a||b|\cos\theta=\Sigma a_i^2+\Sigma b_i^2-\Sigma (b_i-a_i)^2=2\Sigma a_ib_i$$ so that $$|a||b|\cos\theta=\Sigma a_ib_i$$ and the two definitions coincide. You can work the calculations backwards if necessary.