On 2-absorbing commutative semigroups and their applications to rings