Battery A still had potential of 12V, but the battery B showed 0V.
When you connect batteries in series, you have to make sure they are of equal capacity (Ampere hours), equal Voltage and equal wear and age.
Basically you may only create a series pack with two brand new batteries.
This is important to prevent one battery limiting the entire pack. When discharging with unequal batteries your drain one of the batteries to damaging levels, and with charging you overcharge the other.
You can buy lead acid battery equalizers that make sure they are both the same voltage during charging and discharging so they wear out at the same rate.
However, this is not strictly required. But it can be helpful when you have such a heavy load that the differences in internal resistance at high currents have an effect on the balance.
For other battery chemistries, such as lithium batteries, balance is more strictly managed since these batteries are a fire hazard when you (dis)charge them too much.