Usually a camera will report an error code when that happens.
By checking with the Internet you can find out what that code means.
Check the LCD when that occurs and see if there is an error code displayed.
A weak battery can cause the problem and a dropped camera can have the same symptom.
When it happens you can usually assist the lens by gently pulling on the lens housing. That often lets the lens lock into place.
<span id="INSERTION_MARKER">I've had the problem, bad at times even to point of making camera unusable, of when I press the ON button, camera lens does not open (and come out on its short telescope-like thing). Can coax out via >(replay) and Scene buttons. Slow and missed shots. And often when out via ON or coaxed out it would retract immediately.
On 4th time that I took it into shop (having bought 2 new batteries and 1 new charger, all probably unnecessary) tried to show defect - and camera worked perfectly! Was told that there is some safety circuit that makes camera misbehave after it has been shook up a bit, but if left 24 h with battery removed it reprograms itself. It had sometimes been unusable. So now I do that and it is much better, but I would say not quite right, unpredictable and unreliable or not reassuring. It doesn't work then it does. For a time. Today no then yes now no.
Found nothing in manual about it. Is it a known thing or is it just MY camera? Any comments or suggestions?