Losing a data connection to your Internet service provider cannot cause the power to go off for your modem (gateway).
As you probably guess, this is caused by an electrical problem. You will want to find out if the modem is defective, or if the electrical supply to it is causing the problem. This would be sort of like trying to figure out a problem with a stereo, a lamp, or a toaster.
First, are you using the power supply (electrical adapter) that came with it? Check it to see if it matches; though it's unlikely, you could have been sent a wrong one. Disconnect the adapter at the plug and at the modem. Inspect for damage. Reconnect firmly; make sure it's not loose. Plug the adapter directly into the wall, instead of a power strip or surge protector. If it still does the same thing, plug it into a different outlet. If it's still the same, then either your home's wiring has some problem, or the adapter or modem is bad. In that case, probably the adapter or modem, and you'll need replacement for both of them. Try plugging in a lamp where you have the modem plugged in. Does the light flicker, go out, or do anything strange.
Here's my guess: your modem is defective. It could be the power supply (electrical adapter); but you won't be able to tell unless you replace one or the other. If either one is defective, it could damage the other one. That means it could be a really bad idea to replace the modem but use the same adapter! Remember: it doesn't matter how long or short a time the modem worked. It can be bad right out of the box, or work fine for seven years then stop.
It's possible there's another problem, like a bad electrical outlet or defective power strip. That is why you want to troubleshoot (as above). If your modem is not causing the problem, then replacing it won't help. Right? Good luck!