How can I handle feelings and attraction towards the opposite sex so I can stay focused on my ambitions?
Acknowledge them.
This does not mean getting attention and romance and sex you don’t want or giving others attention and romance and sex they don’t want.
It simply means respecting the fact that you have these feelings and not beating yourself (or others) up for having them.
Make whatever ethical decisions you want about them (celibacy, marriage, dating, friends with benefits, casual sex, polyamory, swinging, masturbation, etc.) and proceed with your platonic ambitions.
If you define your feelings and attractions toward others as ambition derailment, you’ll end up resenting and hating yourself and the people you attract and are attracted to.
Do you really want to blame sexuality and romance for your failure to achieve your goals? That’s a spectacularly shitty thing to do to yourself or anyone else.
You haven’t indicated the strength of this attraction (high, medium, low, nonexistent). Again, make whatever ethical decision you want about that, but never blame anyone else or anything else for your personal choices regarding achievement, work, friendship, romance, sex, and love. Find an honorable* way to allow your private feelings and personal relationships to peacefully coexist with your other life goals.
* “Honorable” does not mean the absence of friendship, love, romance, and sex. It means defining for yourself how important they are to you and proceeding honestly, openly, ethically, and without shame no matter what your choices end up being. If you don’t like the way things are going, reassess and readjust your relationship and work goals more to your liking.