Lizards can lose their tails, but not all lizards can grow them back, though. Lizards that lose their tails also lose an important source of energy because they store fats at the base of their tails.
In lizards, the tail bones have central regions that break away easily when the tail is pulled. The muscles of the tail pull apart and the blood vessels constrict to stop the wounded tail from bleeding. So, if a predator attacks a lizard, the tail is designed such that it separates from the body allowing the lizard to escape while the predator gets the tail. Lizards that lose their tails grow them back but the replacement tail is never as long or as colorful as the original one. Replacement tails grow back in as little as three months or as long as two years.
In short, in order to defend it in a threatening situation, the lizard chooses to detach its tail by contracting a special muscle near a weakness in its vertebrae.
In lizards, especially big ones like Iguanas and Komodo Dragons, the tail bones are not designed to break easily and the tail muscles are also not designed to pull apart smoothly. These lizards however can also lose their tails, but it takes a much stronger pull to make this happen. With these types of lizards, the wound heals like others though, but the tail does not grow back.