In the Walden inversion, the backside attack by the nucleophile in an SN2 reaction gives rise to a product whose configuration is opposite to the reactant.
In the next step the hydroxyl group was replaced by chlorine to the other isomer of chlorosuccinic acid 3 by reaction with phosphorus pentachloride.
The intermediates are the carboxyl dianion A which gives an intramolecular nucleophilic substitution by the β-carboxylate anion to produce a four-membered β-lactone ring B.
The α-carboxyl group is also reactive but in silico data suggests that the transition state for the formation of the three-membered α-lactone is very high.
A hydroxyde ion ring-opens the lactone to form the alcohol C and the net effect of two counts of inversion is retention of configuration.