There are a wide range of things that can cause tongue issues, including calcium or vitamin deficiency, trauma, acclimation to lazy feeding habits, etc. In this case, I'm assuming that the chameleon is typically able to feed normally since you didn't mention anything about difficulty feeding, so I don't think it is a lazy feeding habit issue.
There are a couple ways the tongue is held onto the entoglossal process (one of the tongue bones). First, the retractor muscle can be active pulling the tongue pad toward the base of the tongue skeleton and thus hold the tongue in place when already retracted. This muscle is not typically active unless there is some other movement of the tongue or tongue skeleton going on (as during feeding, drinking, etc.). Next, when at rest, the entoglossal process is pointed slightly upward resulting in gravitational pull preventing it from falling off the tip. Finally, the mouth can be kept closed or the the tongue can be depressed into the gular pouch preventing it from falling off the entoglossal process by physically blocking its extension off the tip.
In this case, it sounds like the chameleon is failing to maintain one of those three means of keeping the tongue in the mouth. When it is hot, they often open their mouth to cool themselves off as the mouth is fairly well vascularized and the evaporative cooling helps cool them. In the first pic, it looks like he is leaned forward, which would eliminate the help of gravity to keep the tongue in the mouth. Further, the tongue could have been elevated to help the cooling process. For whatever reason, the chameleon didn't immediately activate the retractor muscle, possibly the result of trauma or calcium/vitamin deficiency. The latter is indicated by the mouth and limbs but if the spindle fibers or other sensory units of the muscle were damaged, there could be a lack of signal returning to the muscle to trigger retraction to initiate retraction.
My recommendation would be to keep him cool, make sure he has the correct lighting, calcium and vitamins and give him some time to recover.
Chris