So I have a script that I moved from one folder to another, reattached it to the object, deleted the old one, and continued writing. But now, whenever I compile, it puts the script back in the old position.
Sounds like either you have some Editor scripting doing that, or more likely you are using a drive mirroring service like Google Drive or One Drive or something.
Drive mirroring is explicitly not supported by Unity. Use properly-configured source control to back up your data.