Mechanism of carboxylic acid and amide dehydration with phosphorus pentoxide
Here is a mechanism for the dehydration of an acid to an anhydride using phosphorus pentoxide.



The $\ce{OH}$ group is not a very good leaving group.  Even in simpler reactions like the dehydration of an alcohol to an olefin we often first convert the hydroxyl group into a better leaving group by protonation with acid or conversion to an inorganic ester (for example using thionyl chloride or phosphorus pentoxide).  The same thing takes place here - we are converting the acid's hydroxyl group into a better leaving group.

Why is $\ce{HPO3}$ such a good leaving group? Look at all the resonance structures you can draw for the anion $\ce{PO3-}$.  It's stability makes the reaction exothermic and strongly drives the dehydration process to the product side.

For completeness, here is a link to a drawing and discussion of the mechanism for the dehydration of an amide to a nitrile using phosphorus pentoxide. Same mechanism and principles (good leaving group, exothermic) as discussed above.