I know that if you have two batteries, battery A and battery B, and connect the negative terminal of battery A to the positive terminal of battery B, there is no potential difference. If you consider the negative and positive terminals of the same battery, the potential difference exists (say 1.5V).
simulate this circuit – Schematic created using CircuitLab
Figure 1. What you are describing. There will be no voltage between the connection point of two batteries as they are directly connected.
I've learned that the potential difference exists because the atoms at the positive terminal have few electrons compared to the negative terminal and so electrons flow to equalize the two terminals.
You have learned incorrectly. All the atoms have the required number of electrons. The potential difference exists to to the chemical reaction of the cell. Current is the movement of electrical charge - either positive or negative - so don't keep thinking of it as "electrons" although they are most common mobile charge carriers. Current can only flow when there is a conduction path from one potential to another.
Why does this flow only occur when it is the terminals of the same battery and not opposite terminals of two different (identical in all characteristics) batteries?
Current can only flow in a circuit and only if there is potential difference (voltage) driving it. By just connecting the negative of BAT1 to the positive of BAT2 you have not created a circuit. It is still an "open circuit" so no current will flow. If you look at Figure 1, what path could the current possibly take?