it is possible the hardware is having some issue. it is also possible that you just have a loose connection for wireless connectivity parts (WiFi and BT)... although, if I recall, those are soldered onto the motherboard.
You could take the phone to UBreakIFix for a check up and if it's damaged see if you want to fix or just buy something new.
Lastly, if it's not a hardware issue. Submit and error report to Samsung Members app right after reproducing the issue. The techs at Samsung will likely be able to help with the issue.
Please provide details of if this happened after an update or just randomly. Additionally, try to boot in safe mode and see if any app is causing this IF you installed any new app in the past few months