Does A now provoke an AoO from B for both entering and leaving these squares, for a total of 6?
No, just 2 attacks are provoked.
Since from Attacks of Opportunity
Moving out of more than one square threatened by the same opponent in the same round doesn’t count as more than one opportunity for that opponent.
The opponent can only ever provoke one attack of opportunity from the same opponent for moving out of a threatened square. Even encircling an opponent, or moving in and out of their threatened squares only counts as one opportunity, provided the movement that provokes is in the same round.
The opponent can provoke more than once though, as explained in the section on Combat Reflexes,
If you have the Combat Reflexes feat you can add your Dexterity modifier to the number of attacks of opportunity you can make in a round. This feat does not let you make more than one attack for a given opportunity, but if the same opponent provokes two attacks of opportunity from you, you could make two separate attacks of opportunity (since each one represents a different opportunity). Moving out of more than one square threatened by the same opponent in the same round doesn’t count as more than one opportunity for that opponent. All these attacks are at your full normal attack bonus.
Hold the Line, presents a different opportunity.
You may make an attack of opportunity against a charging opponent who enters an area you threaten
Even though moving out of a threatened square can only provoke once, the feat grants a new opportunity for entering an area you threaten. Since an opponent can only enter an area you threaten once during a charge, this can only add one opportunity.
If you are wielding a reach weapon and have the Hold the Line feat, a charging opponent provokes when they enter the "area you threaten", thus you would need to make the attack of opportunity with a weapon that has reach.
Strictly speaking, this would not work because attacks of opportunity are resolved just before the action that triggers them, thus the opponent would still be out of reach at the time you make your attack. However, the feat adds this text,
Your attack of opportunity happens immediately before the charge attack is resolved.
The rules don't come out and say you must make the attack with the weapon that threatens, but they do say
An attack of opportunity is a single melee attack
So unless you have another reach weapon, you would need to make the attack with that weapon.
With the second opportunity, provoked by moving out of a threatened square, since an attack of opportunity
interrupts the flow of actions,
the target has not yet left the square, so by the same reasoning, you must also take this attack with the reach weapon.
Thus, to summarize, you would gain one attack of opportunity when the opponent enters an area you threaten from Hold the Line and one attack of opportunity when the opponent starts to exit that same square. Both attacks would need to be with a (melee) reach weapon.