I would argue that the phone switches to external power once it has it, as long as the charger can supply sufficient voltage.
I'm not an expert in this area, but I do know the gist of battery charging. Charging a battery requires applying a high enough voltage on the positive side of the battery. Once you have enough voltage, current can flow through the battery, which is then captured by the battery. If you apply voltage through on the negative terminal, the battery acts as a voltage adder. Since the side of the battery where current normally flows out of is no longer doing that role, it doesn't really make sense for the battery to be powering the device anymore.
So that leaves the question: why is it sometimes if you plug in a shoddy charger, the battery level drops still? The voltage of the charger depends on the limits of its output. If the charger starts running up against its limits, the voltage starts dropping. Once the voltage drops far enough, it's no longer able to shove current into the battery. Note that if two voltage sources connected in parallel have different voltages, the lower one acts more like a load than a voltage source. Hence why the battery starts powering the device rather than the charger.
I have several phones with dead batteries from various brands (old Nokias all the way to iPhones and Androids) and some portable consoles, and none of them work without their batteries / with dead batteries
Unlike laptops where it would still run if their batteries were removed as long as they're plugged in.
Most phone batteries (and likely ones from portable consoles) have a thermal resistor that the device reads to make sure the battery is safe to use. They'll refuse to boot if it's not detected. You can fake this out by adding a resistor of an appropriate resistance.