This happened because you used the same bug for master and 4.0.
The Gerrit hook doesn't verify status between major versions, only inside a single version (for e.g, it would not move to modified if you needed to backport to 4.0.1 and the target milestone was 4.0.1).
I'm not sure how we can tackle this, because master has no meaning in bugzilla, it doesn't correlate to a version.
One think I can think of, is NOT to move bugs to MODIFIED is a patch was merged on master branch... , will that help?