Let T be an arbitrary compact torus. The second cohomology group of BT (with arbitrary coefficients, call that ring k) generates the full cohomology freely as an algebra. In other words, if you pick a k-basis x1, x2,... of H2(BT), then you get an isomorphism of H*(BT) with k[x1, x2,...].
Now let's specialise to the case k=ℤ. In that case, the second cohomology group of BT is canonically isomorphic to the group of characters of T, i.e., to the group of homomorphisms from T → S1. Given a character χ :T → S1, the corresponding element of H2(BT) is represented by (the first Chern class of) the complex line bundle ET ×T ℂχ.
Now back to your question. The elements α1 and α2 form a basis of BT, where T now refers to the maximal torus of G2. So you get an isomorphism H(BT;ℤ) $\xrightarrow{\sim}$ ℤ[α1, α2]. But λ1 and λ2 also form a basis of BT. So you get another isomoprhism H(BT;ℤ) $\xrightarrow{\sim}$ ℤ[λ1, λ2].