BMW was one of the last remaining major automakers unscathed by a shortage of chips expected to cost the industry tens of billions of dollars in revenue this year.