Analysis of the neutron and proton contributions to the pygmy dipole mode in doubly magic nuclei