It's not that the Republicans couldn't pass the AHCA, but that they didn't want to.
It is difficult to just repeal the ACA, which is why the Republicans went from a repeal-only to a repeal-and-replace approach. The AHCA was what Trump and Ryan wanted to use as replacement, but it was widely unpopular among Republican and Democratic politicians as well as the US population in general.
From the NYT article you linked:
House Republican leaders, facing a revolt among conservatives and moderates in their ranks, pulled legislation to repeal the Affordable Care Act
The unpopularity of the Republican health care bill has been shown in a number of polls:
It is also easy to agree to vote to repeal when you know that you can't. Those previous votes were not held to actually change policy, but to send out a signal that all Republicans disapprove of the Affordable Care Act. But not all Republicans – and especially their voters – approve of the new plan, so voting for it is a lot more difficult.
The party was also divided on why they dislike the new bill. The Freedom Caucus thought that the bill did not go far enough:
More conservative members, led by the House Freedom Caucus, were angry that the bill left some of the Affordable Care Act’s insurance regulations in place. Those regulations, they suggested, would keep premiums from falling further ― although the precise relationship between each of these regulations and actual premiums is murky.
And other Republicans thought that the bill went too far:
More moderate members, many of them from Democratic-leaning states and states that used Affordable Care Act money to expand Medicaid, worried that the bill would take away insurance coverage from too many people ― and that, if premiums really did come down, they would do so only by increasing out-of-pocket costs for people who held on to their coverage.