I think it's because they are scared that they might get attracted to someone who is gay/bi/lesbian, so they speak trash, when really the fear that they may not be straight, or completely straight, e.i. bi-curious.
I have met a few people who are straight and do not like people simply because the person is gay.
I am straight as well, but I'm not a homaphobe. It has happened to me before when another girl admits that she likes me, but knows I am straight. It has happened only twice, I believe.
But I did not sqwirm or anything of the sort. I was flattered, that someone liked me and actually admitted it.
However, I am not attracted to girls, but I think it was brave of them to do so.
Not just keep it locked up forever.