HSTS and HPKP are different concepts.
An HTTP Strict Transport Security (HSTS) header instructs clients to use HTTPS for all future connections to a website, thereby preventing downgrade attacks. In contrast to HPKP, it doesn't influence how certificates are validated.
An HTTP Public Key Pinning (HPKP) header instructs clients to pin a specific public key to a domain. So, if a HPKP-supporting browser encounters a HPKP header, it will remember the specified public key hashes and associate them with that domain. In the future (until the specified max-age
timeout expires), the browser will only accept a certificate for that domain if any key in the certificate's trust chain matches one of the associated hashes.
HPKP mitigates the risk of an attacker issuing rogue certificates after having compromised a certificate authority (occasionally happens). Your browser would normally be unable to detect a fraudulent certificate if it has been correctly signed by a trusted CA. (Although there are mechanisms to detect certificate revocations, e.g. OCSP/CRLs.) But if you have pinned a particular certificate to a website beforehand, the attacker won't be able to replace it without triggering a browser waning.
Note that since HPKP is trust-on-first-use, it will (similar to HSTS) only be effective after your first visit to a website. An exception to that are preload lists maintained by browser vendors for high-profile websites (Google, Facebook, Twitter, etc.). This means that even if DigiCert (Facebook's CA) would be compromised today, an attacker would be unable to intercept your connection to Facebook because the original certificates' public keys are preloaded in your browser.