Butter and oils will go rancid if exposed to light, heat or air. For this reason oil should be kept in a cool dark place( when in bottle ). As for butter and margarine if bought but not planning of using them quick, makes sense to freeze the quarter packs and take it to the refrigeration side as needed. For the same reason, all nuts (all have high oil content) should be kept refrigerated or frozen.
If butter has been kept under refrigeration, and there is no visible signs of melting or discoloration, should still be good for at least 5 to 6 months. But a taste test can always tell. If rancid, there is a sour smell in butter and the taste is strong and unusual.
A professional executive chef for over thirty years.