I'm of the opinion that both Messi and CR7 benefited a lot from all time great teammates. In reality, they're not that much better than legends of the past like R9, Cruyff, Beckenbauer, Di Stefano, Romario or Maradona. They were just much more professional/driven for a longer span (15 years) than those other.
The longevity is key, especially CR7. Look at Ronaldinho's level from 03-06. He was incredible. Ronaldo in the mid to late 90s (and a great comeback around 2002-2004). They couldn't sustain it for 10-15 years. Ronaldo's one season at Barcelona is up there with a lot of Messi's but it was only one season.
The other thing as you say is the great players they played with. In the past the talent was more spread out, whereas now all the best players play in the top teams and the domestic leagues are weaker than ever and the top teams win all the time. Penaldo is in the team that have won 9 league titles in a row. Serie A when Ronaldo was in it in the late 90s was near enough the toughest competition in the world to win.
That's partly why Messi and CR7 (despite the 2016 fluke) have never really hit the heights on the international stage. Not at the tournaments.