How does public key pinning work and what problem does it solve?
It means that rather than trusting a central authority for validating the PKI, you are utilizing your own means to determine that a public key is valid. Pinning allows removal of the trust of a central authority and instead takes that responsibility on directly.
The "problem" that it is trying to solve is relying on third party trust, however it requires that proper steps be taken to ensure first party trust and to make sure that revocation is not impeded if the pinned certificate/public key's corresponding private key is lost.
Many techniques can be used for establishing the trust, but some common ones are distributing the pin with an application that requires communication or verifying via an offline side channel. Revocation checking could be done through operating a revocation list similar to how a CA would normally do so, though this takes some more setup to do properly.
There isn't a practical difference between certificate and public key pinning as a certificate is just a public key with details about the holder of the private key. Pinning just implies trust of that cert/key.