For example by definition
1) if g is a factor of a and b and i
2) if d is another factor of a and b then g divides d.
since then divides both and . Hence divides both a and b.
Now supposed d divides and let q be any of prime factor of d. Since d divides a then q must be one of . Then the prime factors of d are also . So we can write where . By doing the same thing with respect to b, we also have . Hence . Then it follows that g divides d.
The same (similar) argument also works for lcm.