Hello!
If your mesh is moving while editing the weights, it means the position of the bones does not correspond to the one when you bound them to the mesh.
A common workflow is to bind the bones you want while in setup mode, because usually in this mode the bones are never moved, unless to fix the way a bone rotates or similar, so if you edit the weights in setup, the vertices should not move.
If you go in animate mode, and move a bone, you'll be able to edit the weights and see the immediate effect of the influence of the weights, this is great to make sure something bends or deforms the way you want it.
However, there is a way to tell a mesh to use a new pose as the mesh's own setup pose, and that is to press the "update bindings" button in the weights panel.
If for example you pressed this button during Animate mode, the current pose of the bones would be stored as its setup pose, causing the vertices to be still when changing their weights only at that precise frame, and moving at any other frame or in setup pose.
This is great to bind the same bones to a completely different pose that you only have in an animation without having to change the setup pose.
You can find more information on this page: Weights - Spine User Guide: Update bindings