People continue to smoke, even though they know it is bad for their health. During the late 1950's Leon Festinger developed the cognitive dissonance theory to explain attitude formation and change. Festinger also theorized that, if a person could sufficiently attribute their behavior to an external influence, his dissonance would be lower and thus there would be a lesser attitude change. For a great example of this, see Supporting Studies Cognitive dissonance explains well the process of effort justification. For example, if someone pays a high price for a new car and finds the car uncomfortable, he may experience dissonance and so to reduce it, he alters his attitude about the car to be more positive.
Cognitive dissonance is by no means a full-proof theory for predicting attitude change.
People do not always change their attitudes when there is dissonance. For one thing, people differ in how much inconsistency they can tolerate. Another thing is that two cognitions that seem inconsistent to one person may not be to another. Still, despite some mixed results, many studies have supported the idea that dissonance does underlie many of our attitude shifts. Self-Perception Theory Daryl Bem developed a slightly different theory than Festinger's to explain attitude shifts caused by behavior.