I've seen this happen on different handsets. It can be caused by certain 3rd Party chargers, no idea why it happens, but cheaper chargers can make the handset freak out and do things of its own accord, much as you've described.
Are you charging when this happens? If not, there might be dirt/dust in the charging port causing it, can you blow it out/give it a clean, see if that makes a difference?
It could be something completely different, but there's no harm giving it a whirl as I've seen this work in the past.