The Federal Reserve’s preferred measure of inflation showed an annual gain of 2.5% in July, within striking distance of the central bank’s long-term mandate of 2%, putting the country firmly on track for a series of rate cuts—likely starting next month.