From the Mayo Clinic website (which is a trustworthy source, in my opinion):
"Rarely, hot flashes and nights sweats are caused by something other than menopause. Other potential causes include medication side effects, problems with your thyroid, certain cancers and side effects of cancer treatment".
Source:
https://www.mayoclinic.org/diseases-conditions/hot-flashes/symptoms-causes/syc-20352790
Consult your GP. He/she will almost certainly want to take into account any medications that you're on and any other symptoms that you might be experiencing (such as tiredness).
It's probably nothing serious but, just in case it is, it's always best to get an early diagnosis.