Warren Buffett’s Berkshire Hathaway Inc. agreed to buy Precision Castparts Corp., the maker of equipment for the aerospace and energy industries, in a deal valued at $37.2 billion, including debt.