Treating phenol with sodium hydroxide first converts it to sodium phenoxide, a far better nucleophile than phenol itself. Heating this phenoxide with carbon dioxide under pressure lets the ring attack the carbon of CO\(_2\) at the position next to the oxygen, installing a carboxylate group there, this is the Kolbe-Schmitt reaction. Acidifying afterward just protonates that carboxylate and the phenoxide, giving salicylic acid, option (B).