Warren Buffett’s Berkshire Hathaway Inc. said second-quarter earnings rose due to unrealized investment gains, while the company’s cash pile grew to a record.

Berkshire on Saturday reported second-quarter net earnings of $14 billion, or $8,608 per Class A share equivalent, from $12 billion, or $7,301 a share, in the year-earlier period.

Operating...