The trick falls in the wording of the problem.
“Now, each of the ladies paid $9. Three times 9 is $27. The waiter has $2 in his pocket. Two plus 27 is $29. The ladies originally handed over $30.”
This phrasing encourages the reader to count the $2 twice.
The $27 includes the money the waiter took and the last $3 was handed back to the ladies. The bill was $25, the waiter took $2 and $3 was handed back to the ladies so there was never a dollar missing. It was simply badly phrased information.