The U.K. economy expanded more rapidly than expected in the first half, placing it on course for a soft landing from the surge in inflation that followed Russia’s invasion of Ukraine, while delivering a boost to the new government as it seeks to end a long period of meager growth.