QCD resummation of dijet azimuthal decorrelations in pp and pA collisions