Two years ago, Matt Kelly couldn’t have known that a failed merger involving his real estate firm would propel him toward a central role in Amazon’s expansion plans.

In May 2016, Mr. Kelly and his firm, then known as the JBG Companies, had an agreement to merge with a large real estate investment trust based in New York. But shareholders of the New York fund balked, and the deal collapsed.

A few months later, JBG, based in Chevy Chase, Md., had a new partner. In a deal valued at $8.4 billion, JBG merged with a Washington unit spun off from the real estate behemoth Vornado Realty Trust.

The new company, JBG Smith, with Mr. Kelly as chief executive, became the dominant landowner in a Northern Virginia region now being called National Landing, a dilapidated area that includes parts of Crystal City, Pentagon City and Potomac Yard. Amazon announced on Tuesday that it was choosing this area, along with New York City, for two new headquarters, with 50,000 employees between them.