Lee Anderson has apologised to the Commons for breaking bullying and harassment rules after a standards watchdog found he twice swore at a security guard when his parliamentary pass did not work.