Energy and centrality dependence of deuteron and proton production in Pb + Pb collisions at relativistic energies