The magazine latch is normaly disabled by the top round remaining in the magazine. When you run out of cartridges the latch activates holding the slide open.
Inserting a replacement slowly into position will generaly not cause the latch to release. If however you insert the magazine rapidly, inertia comes in to play and the top cartridge applies more force on the latch than when gently inserted. There will be intermediate conditions where variations in spring force or insertion speed will result in more or less force being applied generating release variations.
I have seen some people rely on a slam home of the magazine releasing the slide. I don't rely on it but don't object when it happens while inserting a replacement with force.