The dot product or inner product in Euclidean Space $A\cdot B$ has two definitions:
Algebraically defined as: $$A \cdot B = \sum_{i=1}^{n}A_i \cdot B_i=A_1B_1 + A_2B_2 ... A_nB_n$$
Geometrically defined as: $$A \cdot B = \Vert A \Vert \Vert B \Vert \cos{\theta}$$
Is there a way to prove that they are equal other than simply saying they are defined so?
Note that if $A$ and $B$ are vectors representing two sides of a triangle, then the third side is represented by vector $C=B-A$. Let the corresponding magnitudes of the sides be $a,b,c$
The cosine rule tells us that $c^2=a^2+b^2-2ab \cos \theta$
Computing the squares of the magnitudes from the components (using Pythagoras) we obtain $$2ab\cos \theta=\sum A_i^2+\sum B_i^2-\sum (B_i-A_i)^2=2\sum A_iB_i$$and the result follows.
Really this is why the scalar product is a useful definition - if it didn't have this geometric aspect we'd be using a different idea. For example, this captures the idea of the component of a force acting in a given direction.
The scalar product has the advantage of expressing the geometric reality without having to specify a basis.