There is no one correct way to position your fretting hand, but there are many wrong ways.
Playing in the classical style, with the thumb more or less centered on the back of the neck, allows for the fingers to most easily reach up to the low E string and also allows for maximum stretch from index to pinkie finger across the frets, but it also requires a fairly high neck and ideally having the neck at an angle. It also is most ergonomic with lighter strings and lower actions since you want to use the bare minimum amount of finger pressure.
The classical hand position is well suited to fast, light playing and you'll see a lot of highly technical guitarists use this or some variation on it.
What I will call the "rock" hand position is pretty much the opposite. The wrist is much higher on the neck and the thumb is usually wrapped around the top touching the low E string and maybe the A string. There is no gap between the neck and the palm - or maybe more accurately the web between the thumb and index fingers. The neck is more or less gripped with the thumb and fingers wrapped around.
The rock hand position allows a much lower neck and works well for standing up and wearing a guitar low on a strap. It also allows better ergonomics for string bending since you can squeeze the string(s) between the fingers and the thumb and use all of your hand strength to bend. It also allows effective muting of the lower strings while playing single notes and chords on the higher strings. It is better suited to power chords, harder playing, higher actions, and heavier strings than the classical hand position.
The downsides of the rock grip are that it's harder to fret the low strings with the fingers and you don't get nearly as wide a stretch across the frets. One mitigating technique used by many rock grip players is to fret the low E string with the thumb as it's wrapped around the top. The first knuckle of the thumb can be used to fret the low E string.
With either hand position, using light pressure and paying attention to ergonomics is critical to avoiding injury. Generally you want your wrist to be fairly straight or cocked back, not bent upwards. This prevents the tendons for the flexor digitalis muscles from as they go through the carpal tunnel.
There are many positions that are variations of the two above. Those two are sort of the archetypal positions. What you want to do is figure out the hand position that best suits your playing style, your guitar, and your body geometry. It may take trial and error and each hand position makes some things harder and other things easier. Eventually you will want to work on changing hand positions for different needs while still being able to position your hand for maximum comfort.
If you experience any pain or discomfort in your wrist or muscles, take and break (maybe for the rest of the day) and look at your ergonomics when you get back to it. If your hand gets tired, rest and work on perfect finger placement and lightest possible pressure. As you play more and more, look at making sure you have a quality guitar with a good setup and a comfortable action.