A backwater valve stops sewage coming back in
When the sewer backs up, a backwater valve closes so sewage cannot flow back into your basement. While it is closed, your own drains may not empty either, so you need to know how it works and keep it maintained. Installing one needs a permit.
It does not pump out groundwater or stop rainwater running toward your foundation.
A sump pump moves groundwater out
A sump pump pumps out water that drains into the pit, usually from the weeping tile around your foundation. How well it works depends on how much water comes in, the pump, where it discharges, power and upkeep.
It does not clear a sewer blockage or stop all surface water.
Figure out where the water comes from
Sewage backing up, groundwater, water from the roof or yard, and river flooding are different problems. A good plan can use more than one fix, but no device can guarantee a dry basement.