It's great that you're paying attention & wanting to know- it's just that knowing the exact reason is a vague process of elimination & good guessing on your part.
Likely reasons include hunger, looking for more suitable accommodations (more privacy perhaps, or temperatures are too warm or cool), looking for a mate (in mature snakes) & plain old curiosity. I've seen my own snakes, when allowed to explore the floor, head un-erringly to the tiny bit of fresh air coming in thru the sliding glass door that was open just a crack. When we remember how good their sense of smell is, & how much they detect in fresh air, that makes sense.
For safety, when a snake adamantly wants out, it's good to first double-check the temperatures- sometimes a probe gets moved (or other malfunction) & excessive heat can injure or kill your pet. Then consider the other possibilities. Hunger can wait a little while- but safety might not- also make sure the water bowl isn't dry -sometimes snakes spill them or do things with substrate that makes the water wick out & evaporate.