It has to do with the tube on the vacuum. The water moves slower in a bigger tube. So if you have gravel you can use a really small tube and pull the water fast no problem, but the finer the sand is the slower it needs to be to leave the sand in the tank. If you've got superfine sugar sand you just sort of wave the hose over the top to suck up detritus without disturbing the sand. That's good enough because detritus doesn't fall down between the grains the way it does with gravellier stuff.
If you're having a lot of sand sucked up you can pinch or bend the hose part to slow it down. With normal sand you want enough flow to tumble the sand around in the tube and suck out the dirty water but not enough to pull out the sand. It's a balance where the flow is strong enough to lift heavy turds and stufff but not the sand. It's normal to lose a little sand, I'd say less than a 1/4 cup goes down the drain when I do a 10g change. That's actually good because the sand can soak up nutrients from the detritus over time so it's good to replace it gradually over the years to prevent it leaching phos into the tank later.