It's much easier to use apps that support end-to-end encryption than it used to be, but it's still good to know how it works. https://ssd.eff.org/module/deep-dive-end-end-encryption-how-do-public-key-encryption-systems-work
A Deep Dive on End-to-End Encryption: How Do Public Key Encryption Systems Work?

If you haven’t yet, we recommend reading a few guides before this one, to help cement some of the concepts discussed here: What Should I Know About Encryption?, Key Concepts of Encryption, and Key Verification. If used correctly, end-to-end encryption can help protect the contents of your messages, text, and...

@eff I read it but cannot find/understand how the private key is exchanged. If the public key is used the server of a messaging service could store it withe messages. And decode it when needed. Including the private key that is sent encrypted with the public key.
Or are all these applications using decentralized networks?