When the //expand command is used to make a selection that goes over the top limit or under the bottom limit (for example //expand top 255 in a selection at ground level) the selection is made over the limit as asked. But if this selection is used to //set some block, then this block is set on the whole height of the world, even outside the selection (on the top if the selection goes to the bottom or on the bottom if the selection goes to the top). And the changes made outside the selection cannot be undone.