In Penta-1,3-diene all the four carbon atoms having sp2 hybridised and in conjugation while in case of penta-1,4-diene one carbon between two double bonded carbon is sp3 hybridised hence de localisation not possible.
The remarkable basicity of guanidine is attributed to the fact that the positive charge on the guanidinium ion is delocalized equally over the three nitrogen atoms, as shown by these three equivalent resonating structures: