Racist and sexist messages on social media were attributed to a candidate on the BBC show, prompting an apology.