I am trying to understand how encryption works.

My understanding is that the key is sent with the cipher text. If this is true, I do not understand how an attacker could not get the key. If it is not true, I do not understand how the intended recipient could get the key they need to decrypt it.

Can you please explain?