When a carboxylic acid acts as a nucleoplile, why does it attack through the carbonyl bond?
For both the examples that you mentioned, the carbonyl oxygen has its lone pair localized while the other oxygen's lone pair is delocalized with the double bond. The better nucleophile is the one which has greater electron density.