A former One Nation candidate has apologised for describing gay people as having a mental illness, saying he was repeating something he "heard people saying on social media".