Machado homers to lead Padres to 3-1 win over Giants