For example, let's expand out (x+3)*(2x+1). Use of the FOIL rule should get to you 2x^2 + 7x + 3.
Now imaging that you handed 2x^2 + 7x + 3 to a friend to be factored. They do not know the factorization yet.
They would see that a = 2, b = 7, c = 3.
The friend needs to find two numbers u,v such that they multiply to a*c = 2*3 = 6 and add to b = 7
Through trial and error (I recommend making a table of values), your friend would get
But as you mentioned, your friend could easily swap the order of addition and multiplication to say
----------------------
If we go with the first option, then the factor by grouping looks like this
2x^2 + 7x + 3
2x^2 + 1x + 6x + 3 ... break up 7x into 1x+6x
(2x^2+1x) + (6x+3) .... group up the terms into pairs
x(2x+1) + 3(2x+1) .... factor each grouping
(x+3)(2x+1) ..... factor out the overall GCF
---------------------
Or we could have the factor by grouping looks like this
2x^2 + 7x + 3
2x^2 + 6x + 1x + 3 ... break up 7x as 6x+1x
(2x^2+6x) + (1x+3)
2x(x+3) + 1(x+3)
(2x+1)(x+3)
(x+3)(2x+1)
We end up with the same factorization.