It's probably curiosity. Entering the room is likely noticable to the snake and it's attempting to see what's going on.
It could also be supersticious behavior due to intermittant reinforcement. By sticking its head out, it gets food. Sometimes it works, ergo it must stick its head out to get food. They aren't super smart, but psychological conditioning can still affect it.