CO2 can increase the earth's temperature due to the greenhouse effect (blocking the reflection of IR radiation), but the inverse is also true. I.e. when temperatures rise, more CO2 (for example from the ocean) will be released in the atmosphere. There is thus a positive feedback between temperature increase and CO2 emission, both causing each other.
Fortunately, this process will eventually reach a stable equilibrium. This means that if we emit a certain amount of previously stored CO2 in the atmosphere, the temperature will slightly increase, causing more CO2 to be emitted from e.g. the oceans, which in turn causes a slightly further increase in temperature, etc. Eventually, this will reach an equilibrium where both the temperature and the amount of CO2 in the atmosphere will have increased by a certain amount.
Paleoclimatic Ice Core data shows us that when temperatures rose in the past due to changes in the sun's activity or changes in the earth's orbit around the sun, CO2 levels have risen as well. Since a rise in CO2 levels leads again to an increase in temperature, these changes in CO2 levels throughout history have helped us to precisely model the feedback between a rise in temperature and an increase in CO2 levels.
Some people incorrectly use this 'increase in temperature causes increase in CO2 levels' argument to argue global warming is not man-made. It is however, important to realize that both cause each other. In addition, there are various kinds of evidence supporting that the recent increase of CO2 in the atmosphere over the past 50-100 years has been initially caused by humans burning fossil fuels (e.g. this can be seen from the fraction of C14 isotopes in the atmosphere) and is not caused by an initial rise in temperature. It will however have a rise in global temperature (and a further rise in CO2 levels) as its consequence.