I always try to think of snakes as very simple minded creatures, working with some very old, steadfast and hardwired brains. Their first need is to survive. Whether that be through hiding, fleeing, fighting, mating... they all have the very basic need to survive.
I believe they work on some very basic instincts, and can learn easy simple patterns if repeated often enough and in an environment that makes them feel secure.
If your snake recognizes you as the warm object that does not drop him, then kudos! That's all he thinks when he smells or feels you. Your the big thing that bothers him everyday while he's trying to sleep. You have been holding him and teaching him to tolerate being held by you. He feels safe enough that you wont eat him. Good job.
When you put him back in his cage after holding him, he will either go to the place he knows as home, or he will try to flee in distress. Or as some call it "Come back out to play with me".
We make it our mission to direct our snakes back into the dark hide inside their tub. We show them the dark entrance, and they usually make a run (or slither) for the hide. The only dang one who refuses this is the boa. He is neither secure with us, nor wants to be held. We are still working with him. lol.
I also believe that some snakes are more skiddish than others and can be worked with everyday, but deep down their hard wiring wins out. Wild animals aren't supposed to be comfortable with us to ensure their species survival, some don't ever get over that.