While I don't know what's causing it, I know how to work around it based off experience. The IVs MUST be the last thing you edit for the Pokemon, as if you edit the IVs and then change the moves/item/abilities/evs of a Pokemon, they'll become the default 31/31/31. If the IVs are the last thing edited and you go on to edit a different Pokemon, the IVs should remain just as you set them. Showdown likely does this, as you typically want 31 on all your stats.