DIAGNOSIS The washer's control board isn't getting the "lid is locked" signal from the latch assembly. Either the latch mechanism is faulty, or the wiring to it is damaged.
FIX Unplug the washer. Look at the strike plate on the top edge of the door opening—that's the part the lid latch clicks into. Sometimes it gets gummed up with detergent or fabric softener. Clean it thoroughly with a damp cloth. Also, manually press the little plastic plunger in the center of the strike plate a few times to make sure it moves freely. Plug it back in and try.
IF THAT DIDN'T WORK The lid lock latch assembly itself (the part on the underside of the lid) likely needs replacement. It's a common failure point. You can test it by checking for continuity across its terminals with a multimeter when the lid is closed, but usually, it's just easier to swap the part.
HEADS UP Never try to bypass the lid lock switch. The washer will not agitate or spin with the lid open, and disabling this safety feature is dangerous.