How can a battery charge up another battery to a higher percentage?
Sometimes it is easier to understand circuitry in the context of water. What you're imagining is two tanks of water of equal size linked together by a pipe that has been sealed off. If one tank holds 5% water and the other holds 35% water, when you remove the seal, the tanks equalize and you end up with 20% in both tanks.
What you're forgetting is that like batteries, water tanks come in varying capacities. A large battery pack "water tank" is more equivalently like a tank 4 times the size of the phone "water tank". When you release the seal, the phone water tank is filled easily and the source, the battery pack water tank still has plenty of water. Charge works similarly, except you cannot "see" charge like you can with water in a water tank.
So what happens when you have a large tank with water at the same level as the smaller tank? Despite the larger tank holding more water, since they are at the same water level, they are at equilibrium and so one doesn't "charge" the other. Likewise a sufficiently uncharged battery, even with plenty of capacity, can have low charge and not charge the phone.
Hope that explains it.
Edit: In light of several comments, perhaps it would be imprecise to imagine two tanks one next to the other, but rather it would be more accurate to imagine the large battery tank on top to fill the phone battery tank below, since potentially all of the charge could transfer from the large battery pack to the phone battery.
The key here is the voltage of both the batteries. The battery in the phone is generally at a voltage of 3.7V. The battery pack has a higher voltage or a circuit which gives a voltage of 5V to your phone. So, as long as the voltage with which you charge the phone is higher than that of the battery, the percentage of power in it doesn't matter and the phone charges up.
Connecting your phone to the battery pack doesn't directly connect the cells in parallel. I assume this is where your guess of an equilibrium with equal voltage -> equal charge percentage comes from.
Shorting lithium-ion / lithium-polymer (LiPo) cells together like that would likely cause one or both to literally catch fire from the high currents, or from overcharging / over-discharging. (Circuitry to prevent over-discharging even if the charging cable is shorted out is absolutely essential).
There are some links to youtube videos of lithium battery fires on a recent electronics.SE question about designing your own charger. (TL:DR: it's way the hell too dangerous to consider doing for a homebrew design, because Lithium cells need a LOT of protection circuitry to be mostly safe.)
So the whole idea of connecting cells together and letting their voltages equalize "naturally" is just completely not viable for modern batteries.
Chargers use DC-DC switching power supplies to charge at constant current. They use inductors to efficiently convert to a different voltage (higher or lower). (For example, to produce a lower voltage, see this detailed explanation of a buck converter doesn't use a transformer, just an inductor. Also a discussion of multi-phase buck converters used on computer motherboards.)
In the water analogy, where water represents charge and pressure represents voltage: A converter is like a pump that can move charge from a lower reservoir to a higher reservoir. (voltage = pressure = gravitational potential energy (per unit volume / charge).) A small fraction of the energy transferred is lost to inefficiencies in the conversion. (Maybe a couple %, IDK).
Since the capacity of the external battery pack is larger than the capacity of the phone's battery pack, it should be obvious that moving charge from the large reservoir to the small reservoir can take the phone battery from 5% to 100% while only dropping the battery pack from 35% to 12%. I don't think this is what the question was really about.
Just to make it even more obvious why batteries aren't just connected together to equalize: Some batteries may have multiple cells in series instead of one large cell. This is typically for physical design reasons, more than to get a higher voltage, because DC-DC converters will be used anyway to produce supply voltages in the 1 V to 2 V range to power most electronics.
Since Lithium cells are so finicky and dangerous, wiring them in parallel instead of series is unwise. One cell could end up taking most of the current. So instead, they're wired in series with circuitry for each cell to bypass it before it overcharges or undercharges.
The power transfer between phone and battery pack happens over a USB cable, which runs at 5 V. (Or, with USB power delivery signalling, the device being charged can signal that it can accept up to 20V, allowing for higher power at the same current to reduce resistive losses and allow faster charging without exceeding safe current limits for the cable / connectors.)