HTC showing a weird screen?
What you saw is likely the HTC Dot View. It's an interface that works with certain protection sleeves, that shows time, notification and other info through a stylish, easy-to-read "dotted matrix".



However, if your phone isn't wearing such a sleeve when it happens, it's advised that you check for magnetic sources around it, which could trick the phone into thinking it's paired with such a sleeve. You said "After this happened my phone sometimes turns on by itself" - further reinforced my speculation that it's some (unstable) interference from a random magnetic source around.