Starting with Xcode 9 or so, Xcode by default keeps the on-disk layout of a project in sync with what you see in the Project Navigator. So when you move a file from one group to another, it will be moved between the respective folders on disk as well.
You can explicitly disable this behavior for a given group in a few different ways:
- Select “New Group without Folder” when creating a new group
- Remove the folder association from the group by clicking the (x) icon in the File inspector
- Disable it globally by setting a user default on the command line
$ defaults write com.apple.dt.Xcode IDEDisableStructureEditingCoordinator -bool true