Carbon dioxide and methane are two of a number of so called "greenhouse gases". Greenhouses gases are responsible for the relatively warm temperature of the atmosphere. Without the blanket of greenhouse gases, the Earth would be a frozen ball of ice. The gases of our atmosphere are known as "selective absorbers" of radiant energy. That is, a particular gas absorbs and emits energy well at some wavelengths but not at others. Solar radiation (shortwave) passes through most of the atmospheric gases without being absorbed to a significant extent. However, longwave radiation emitted from the Earth's surface and directed toward the sky is readily absorbed by greenhouse gases. When absorbed, the temperature of the atmosphere increases. Some of this absorbed energy is emitted to space while some is emitted back towards the Earth. This is the basis for the greenhouse effect.
Though all atmospheric scientists agree there is a greenhouse effect, not all agree on the impact that human beings are having on it. In particular, many cannot agree that the warming we are currently experiencing is a product of human activities. Analysis of ice cores has shown a significant variation in the carbon dioxide content of our atmosphere which has affected global air temperatures since the great ice sheets marched across warmer periods associated with higher greenhouse gases and cooler with less. But for the last several decades, greenhouse house concentrations are up and the earth's atmosphere has been warming. The consensus is that human contributions of greenhouse gases are the reason.