The tests are there to ensure that the emergency alert system works. EAS works by using special hardware to interrupt the normal broadcast and replace it with the alerts broadcast. TV and radio stations don’t make money off of the hardware, so they have little incentive to test it themselves. So EAS test alerts are sent out on a regular basis to ensure that each station has working hardware.
A real EAS message is much more noticeable than a test. Viewers are highly unlikely to mistake a test for a real one.