Either Hamas are trying to use Palestinians as human shields by ordering them not to move, (This will be the western narrative). OR they understand the dangers this will pose and are trying to keep the people safer.
They should be safe in side UN compounds, which are usually well marked on maps, well marked from the air and ground so to avoid them being targeted.