Italy won the Davis Cup for the fourth year in a row as they battled to victory over Carlos Alcaraz and Spain in front of a jubilant crowd in Bologna.