Melody is a pretty lousy way to do mezzing, at least for me, it's easier with full manual control. If you start singing mez on a mob and leave it running, it will continue to mez that mob until you stop the song. It doesn't matter if you have anything targeted or not, or switch targets. When you start the song, it plays on whatever is on your target at the start of the song. Leaving it running continues to refresh it on the song's original target. This is why you can start casting mez on one mob, and switch targets and melee a different one.
In order to mez a new target, you have to start a new mez song with a new target. If you want to use /melody, let's say mez is spell gem 1 - you can do /melody 1. /Melody 1 will restart the mez song each time for you, it's up to you then to make sure it has the target you want before the next song starts.
If I'm mezzing one mob, I often leave my melody running and stop it after the third song, and sing mez, then restart the melody again. I choose a song I don't care about having up for my fourth melody position, and that's where I manually insert mez, between restarting melody again.