You did not use any EVENT, either → onChange( ) , nor onClick( ) !
Additionaly you will recognize, that you also should use → blur( ) .
$w('#cb').onClick(()=>{
if ($w('#cb').checked){
$w('#cb').style.backgroundColor = "#E8E8E8"; $w('#cb').style.borderColor = "grey";
} else {$w('#cb').style.borderColor = "red";}
$w('#cb').blur();
});