The failure of the Keystone XL project demonstrated the challenges of building new pipelines in the U.S. and Canada amid galvanized environmental groups and delivered a blow to oil-and-gas companies that now must rely on aging infrastructure.

Protesters targeted Keystone XL, which Canada’s TC Energy Corp. TRP -0.26% abandoned Wednesday, and other pipelines for more than a decade, hoping to choke off fossil-fuel usage by making it harder to transport. The success with Keystone XL already has emboldened environmentalists, who in recent weeks have turned their attention to other pipelines in the U.S. and Canada.

But the U.S. and Canada still rely on pipelines to transport fossil fuels that underpin commerce, transportation and heating and cooling. As pipelines become increasingly difficult to build, the countries will become more dependent on older infrastructure that is vulnerable to disruptions. The shutdown of the Colonial Pipeline last month after it was attacked by hackers highlights the potential impact caused by unexpected disruptions to the current network.

“Clearly, we’re relying on the infrastructure we currently have. The question becomes, as we think about filling future demand, and we need to repair or replace old infrastructure, how are we going to handle it?” said Amy Myers Jaffe, a research professor at Tufts University’s Fletcher School.

Global oil demand is projected to peak in coming years, which could mean projects like Keystone could eventually outlive their utility, Ms. Jaffe said. “We’re not building for the 1950s, we’re building for the 2030s.”