More than 24,000 BMW and Mini cars have been called back to fix a leak in their exhaust systems that could start a fire.