This is an interesting question and probably one that a lot of other people have. In the case of attraction, having a firm sense of boundaries (but not shutting the other person out entirely) would help. Have a plan in place for how you respond when you notice the attraction. It seems like this is a pattern for you, so changing the way you respond is key to altering the pattern to something that would feel more balanced and healthier for you.
I have not experienced discomfort with people of the same gender, but again, this may be more common than you think. Worrying less about gender and focusing more on what you have in common may help here. I'm not much of a talker, but I pay attention, especially when someone mentions a thing they're into - a band, a television show, a hobby. Then I try to hone in on those things for conversation pieces when I feel at a loss. Focus on things that are universal across all humans. Joking and humor is an example. Everyone loves to laugh.
Thank you for the great question. This may be something I can cover more in another article.