Why do my earbuds keep changing the volume up and down whenever I move the wire?
My guess would be that you are in a noisy environment, using your earphones, as you say, plugged into your phone.

This happened to my while riding my motorbike with earphones on. The built-in microphone is being hit by a lot of noise, and then the signal is sent and your phone OS tries to protect you by lowering the volume.

Try the same earphones with some tape on the microphone (a tiny hole somewhere on the earphones), or try them in any situation without a lot of outside noise.

If they work ok, your problem is what I'm telling you about.

There is a few choices you can take to fix your problem. I'll state them so the first options are the cheapest or more reasonable ones.

1. Search for a setting on you IOS, or an app to make volume not depend on outside noise. There is some apps that lock the volume level I think.

2 Put some tape or whatever you consider to make your microphone deaf.

3 Change earphones to ones without built-in mic.