NEW YORK — Bill Gates and Warren Buffett, the two richest Americans, share a friendship, a commitment to philanthropy and an interest in railroad investments. In 2014, Gates’s trains are the better performers. Canadian National Railway Co. (CNR) is beating benchmark stock indexes as profits and shipments surge, a boost for Gates, the largest shareholder. At C$64.7 billion ($59.2 billion), the railroad today passed Suncor Energy Inc. (SU) to become Canada’s fourth-largest company by market value. BNSF Railway Co., owned by Buffett’s Berkshire Hathaway Inc. (BRK/B), is struggling. North America’s biggest railroad by sales is grappling with slow traffic and is being scrutinized by U.S. regulators for poor service, spurring concern that it risks a permanent loss of some customers.