This is a common question, believe it or not. It sounds like you may be suffering from bruxism. Bruxism is the medical term for clenching your teeth. Which in and of itself sounds like a fairly benign thing, but it can actually cause some fairly significant problems if left untreated over time (such as tension headaches, and significant enamel wear leading to decay). The muscles of mastication (involved in chewing) have neural control that can be both conscious (you can control it), and subconscious (you don't always have to think about chewing). This is similar to the respiratory system and control of your breathing (Thankfully we don't have to be conscious to continue breathing, or at night we wouldn't do so well). There are many theories about bruxism, but one of them is that at night while sleeping the subconscious for whatever reason causes you to clench your teeth (and even grind them from side to side at times). Strictly speaking bruxism as a term isn't exclusive to this occurring at night, it sounds like what you have is actually nocturnal bruxism. Why does this occur? It's unclear. It is a behavioral pattern, and some theorize that the inciting even is typically some sort of stressor, or event (stressful time in your life, etc). What is known, is that the process can continue on even after the event has passed. There are definitely treatments for bruxism, one of the most common being to wear a specifically fit mouth guard at night. I would definitely recommend going to your dentist
to discuss your concerns and to get a thorough exam of the wear on your teeth. I hope this helps, and best of luck.