In most cases, an air conditioner freezes because the refrigerant expands more than it should or because the air conditioner can't draw enough warm air from the structure it's cooling. There are a number of causes of both of these problems.
After trapping heat from inside the home and being compressed, refrigerant creates the cold air in an air conditioner by re-expanding. If it expands too much, perhaps through a problem with the piping, it can reach a temperature below freezing and cause ice to form. If an air conditioner's intake is blocked, it might not be able to capture the warm air needed to run optimally.