Italy moved level with Brazil at the top of Confederations Cup Group A after a 2-1 win over Mexico at the Maracana.