On your motherboard you'll find a coin cell battery (the CMOS battery). That battery is likely either disconnected or dead. You can fix this by replacing the battery and making sure it has a solid connection.
Usually they're a CR2032 battery. You can get them for a dollar or two.
It's also possible that your motherboard has two jumper posts for resetting your motherboard's BIOS, the jumper could be on those posts, or something else could be shorting them causing your BIOS to reset. I haven't seen these on more modern hardware though.