Unfortunately, if you guys want to be able to play when the other one is offline, you’ll have to set up a dedicated server and leave it running.
Activating co-op using the main menu simply takes the single-player game and makes it open to other players as long as the co-op session is running. You have your own single-player world on your machine and your friend has his. So when your friend activated co-op, he opened his single-player world to you. When you select the same options from the main menu, you’re opening your single-player world.