In international relations, some scholars believe that conflict comes about (or does not) based on the self-identity of various countries and their people. In other words, Country A and Country B might come into conflict if their visions of themselves are incompatible. Country A and Country C, meanwhile, may enjoy peace because their visions of one another do not come in conflict.
During the early part of the Cold War, the US seemed to identify itself mainly as an anti-communist country. Based on this self-identification, the US came in conflict with countries that (to the US) seemed to be communist. By contrast, the US maintained peaceful relations with countries that were anti-communist, regardless of whether those countries were democracies or dictatorships.
By the time that detente happened, the US vision of itself had been changed by the Vietnam War. The US stopped perceiving itself solely as a bulwark against communism and started to see itself as a nation that could be more dedicated to peaceful coexistence with all. Because of this, one can argue, the US stance towards the USSR and China moderated.
Please note, however, that realists would not accept this explanation at all. They would argue that both of these policies came about because each was the best way for the US to maximize its power and security at that particular time.