PRETORIA, South Africa—BMW’s assembly plant here is getting some of its power from cow manure. The company has agreed to a 10-year deal to buy as much as 4.4 megawatts of electricity from a biogas power station about 80 kilometers from the assembly plant. Surrounded by land where approximately 30,000 cattle graze, the power station runs off gas emitted by a fetid mixture of dung and organic waste.