Price and cost are independent variables. People are willing to pay a given price regardless of what it costs to produce the good.
If you can reduce your costs without reducing the price people are willing to pay, your profits go up.
If your costs go up at the same time your competitors' costs go up, everyone raises their prices. Consumers either pay the increase or they buy less. If they buy less, everyone lowers prices and eats a smaller profit margin.
If your costs go up, but your competitors' costs don't go up, you eat a smaller profit margin. If you were already too close to 0% -- and BP was nowhere close to that -- then you can't afford to keep producing. You either operate at a loss until things change, or you go out of business.
The whole "pass it on to consumers" meme is a right wing talking point designed to prevent ever assessing reasonable costs to business, since "they'll just pass it on to consumers anyway".