Phone randomly asks me to re-enter the SIM Card pin code :(

My HTC One M8 randomly asks me for the SIM Card pin code, sometimes several times during one day, sometimes only once or none. It's very annoying since I don't have network until I re-enter the pin code. It started on itself a couple of weeks ago, I did a factory reset but it didn't helped. I am with the stock 6.0 sense rom.
Anyone experiencing the same problem? Is there a way to I fix this?

Maybe your SIM tray is loose or damaged, which would cause the card to be detected as newly inserted every time.

Thanks.
Yeah, or it could be the chip on the motherboard itself, which is even worse.
I was hoping that this was a know issue on the M8 and someone could give me a tip if it has a solution or if I just go for the HTC 10...

Try cleaning the tray if possible or taping a small piece of paper (usually a tiny cut-out from a business card helps) to the back in case the SIM is getting loose. Just be careful with that one; make sure that if you do that you'll be able to remove the card WITH the paper if needed or that it doesn't go in too tight.

Try cleaning the tray if possible or taping a small piece of paper (usually a tiny cut-out from a business card helps) to the back in case the SIM is getting loose. Just be careful with that one; make sure that if you do that you'll be able to remove the card WITH the paper if needed or that it doesn't go in too tight.