The Kli Yakar (Kli Yakar on Devarim 1:37) establishes the causal chain explicitly: because of the sin of the spies Israel was delayed forty years in the desert, during which Miriam died, the well ceased, and the waters of Merivah incident followed — concluding that "if the spies had not sinned, they would have entered the land immediately along with Miriam, and Moses would not have come to this punishment," making the sin of the meraglim the root cause of Moshe's exclusion from the land.
The Or HaChaim (Or HaChaim on Devarim 1:37) addresses the apparent contradiction directly, acknowledging that Moshe's death in Transjordan is attributed to Merivah, yet arguing that had Moshe spoken to the rock and thereby sanctified G-d's name on a grand scale, Israel would have recovered the spiritual level they held before the sin of the spies, and G-d would have cancelled His oath barring Moshe from entering the land — thus tracing the ultimate decree back to the spies' sin.
Rashi (Rashi on Devarim 3:23–26) similarly connects Moshe's punishment to Israel's conduct rather than to Moshe's personal failing alone, citing the pasuk in Tehillim (Tehillim 106:32) that "they provoked Him at the waters of Merivah, and He did evil to Moses on their account" — reinforcing that the people's behavior, set in motion by the episode of the spies, bore responsibility for Moshe's fate.