About the first fact see <a href="http://groupprops.subwiki.org/wiki/Direct_product_is_cancellative_for_finite_groups">this </a> page (the Krul-Remak-Schmidt theorem). For infinite (even finitely generated) groups the situation is different because there exists an infinite f.g. group isomorphic to its <a href="http://groupprops.subwiki.org/wiki/Group_isomorphic_to_its_square">direct square. </a>