The key to understanding expanding brackets is to understand that we need to multipy EVERYTHING in the first bracket by EVERYTHING in the second bracket.
We can think of the calculation
(x+a)(x+b)
as
x(x+b) + a(x+b)
(by simply splitting up the first bracket).
Multiplying out both brackets then gives
xx + xb + ax + ab,
which is equal to
x2 + ax + bx + ab, which is our final answer.
Example: Expand (x+3)(x+4).
We can think of this as
x(x+4) + 3(x+4),
which we can see is equal to
xx + 4x + 3x + 12,
so our final answer is
x2 + 7x + 12.