Just a cursory internet search gave me this: "Saint
Joseph's name is always followed by the letters “P.P” for pater putativus (commonly accepted) father of
Jesus Christ. In Spanish, the letter “P” is pronounced “peh” giving rise to the nickname
Pepe for
Jose.”
But this is a rare case as most Spanish diminutives (or most other diminutives really) aren't that logical.