The "pulling out of the sum" is a consequence of the properties of bilinear forms:
http://en.wikipedia.org/wiki/Bilinear_form
If $B$ is a bilinear form, then certainly $B(v_1\mathbf{b}_1 + v_2\mathbf{b}_2, \mathbf{w}) = B(v_1\mathbf{b}_1, \mathbf{w}) + B(v_2\mathbf{b}_2, \mathbf{w}) = v_1B(\mathbf{b}_1, \mathbf{w}) + v_2B(\mathbf{b}_2, \mathbf{w})$. By induction then,
$$ B(v_1\mathbf{b}_1 + v_2\mathbf{b}_2 + \cdots + v_n\mathbf{b}_n, \mathbf{w}) = v_1B(\mathbf{b}_1, \mathbf{w}) + v_2B(\mathbf{b}_2, \mathbf{w}) + \cdots v_nB(\mathbf{b}_n, \mathbf{w}).$$
In other words,
$$ B\left( \sum_i v_i\mathbf{b}_i, \mathbf{w} \right) = \sum_i v_i B(\mathbf{b}_i, \mathbf{w}).$$
In a similar way,
$$ B\left( \mathbf{v}, \sum_{j} w_i\mathbf{b}_j \right) = \sum_j B(\mathbf{v}, \mathbf{b}_j)w_j.$$
So, if $\{ \mathbf{b}_1, \ldots, \mathbf{b}_n\}$ is a basis, we can write uniquely,
$$ \mathbf{v} = \sum_i v_i\mathbf{b}_i $$
and (using a different index variable to avoid confusion later):
$$ \mathbf{w} = \sum_j w_j\mathbf{b}_j $$
The result you quote above follows from combining it all into one expression.