Babar Azam smashed a brilliant hundred as Pakistan defeated New Zealand by 38 runs in the second T20I at the Gaddafi Stadium, Lahore.