The message is being encrypted with Bob’s public key, which is available to everyone, that is how Alice has access to it. However, Bob’s private key is the only key that can decrypt the message. Bob’s private key is only available to him. That is how the contents of the message stay secure.
I found this video helpful as it does a good job visually displaying the process. Hope that clarified any confusion!