If you have an online account and you are using the app across all of your devices, then your messages are stored in the cloud. That is how you are able to access those messages and restore them across devices. All of your messages are stored end-to-end encrypted. No one can look at their contents without your specific email and password combination. For more detail on the encryption, please just search encryption on this page. That topic also provides a technical overview of encryption.
If you don't have an online account, we don't store anything. If you delete your account, the messages are deleted from the cloud. The data is just dead space to anyone but you, due to the encryption. We cannot do anything with that data. If an account is deleted, the data in it is deleted.