2 can be taken common because there is 2in first term and there is 6 in second term and 2 can exactly divide 6 .there is a*a in first term and only a in second term so u can take a as common.There is only b in first term and b*b in second term so take u can take b as common.