imagine a force of 3N acting 45 degrees to the horizontal. in GMA, you might've learnt about resolving the force into two components - one horizontal and one vertical. in this case, the horizontal force is
)
(using trigonometry) while the vertical is
)
. what have we done? we've found the lengths of two components of the force.
but to do this, we had to know what was the angle between the force and the horizontal, what if we didn't or instead we were given vectors? this is when scalar and vector resolutes become helpful.
say we have two vectors,

and

, we want to find the scalar resolute of

in the direction of

, in other words, how much

'moves' in the direction of

. if we knew the angle, it would just be
)
where

is the angle between the two vectors. but we don't know the angle, instead we are given vectors. we know that
 \implies \cos(\theta) = \frac{\mathbf{a.b}}{\mathbf{|a||b|}})
. substitute this into the formula before and we get

which is the formula given in some books.
now, for vector resolutes. using the example at the start,
)
is just a length, it could be pointing anywhere. we want it to point in the horizontal direction, so we scale the unit vector

which represents the horizontal with
)
to get
\mathbf{i})
as the vector resolute.
what did we do just then? we found a vector in the direction of the horizontal but with the length of the scalar resolute. in general, if you want to find a vector in the direction of

but with length

you multiply

by the unit vector of

that is, you want the vector

.
so, we want a vector in the direction of

but with length

, which is the vector

.