We are learning factoring by grouping - The teacher explained the process but didn't explain the logic behind it. You need to multiply the coefficient on the x-squared term by the constant to get a number. You then need to find two numbers which multiply to this number, and add to the co-efficient on the x-term. Then you split the x-term between these two numbers, group them, and factor them.
Why does this work?
So, you're given $ax^2+bx+c$, and you want to find $d,e,f,g$ such that $$ax^2+bx+c=(dx+e)(fx+g)$$ Multiply out the right side, and what we want is $$a=df,\quad b=dg+ef,\quad c=eg$$ The first step in the process gets you the number $ac$, which is $dfeg$. So you are trying to split $dfeg$ into two factors that add up to $dg+ef$. Those two factors are going to be $dg$ and $ef$. I'm not sure what you mean by "group them", but you factor them as $d\times g$ and $e\times f$, and then you have the numbers $d,e,f,g$ that you're looking for.