The phone is not running Samsung’s official software

Does anybody why my Samsung a40 phone briefly in red text say "The phone is not running Samsung’s official software." and then booting to Download mode. I got this error after trying to flash Twrp.