Does P2PKH substitute P2PK in any circumstances? Why? Does P2PKH substitute P2PK in any circumstances? Why? I know address(public key hash) was invented later than the official implementation released. Is it the reason?
Both P2PK and P2PKH were part of the first bitcoin 0.1 release, so that second point isn't true.

P2PKH is theoretically safer because the pubKeyScript only reveals the hash of the public key rather than the public key itself (which only matters in the case that the elliptic curve crypto involved is broken). So as long as you don't reuse the address, no-one else will know the public key before the money is spent.

All bitcoin addresses encode public key hashes so only P2PKH can be used with an address, as the public key is not known. P2PK were mainly designed for IP-to-IP payments, which is no longer possible in Bitcoin Core since version 0.8.0