Download a picture of a naked Nasty Pelosi. That will kill your erection and libido for some time.
Your erection is a sign if being very healthy mentally and physically my friend. In your subconscious your brain knows that you're about to make your penis bigger and satisfy women like never before. That subconscious awareness triggers a signal from the brain to prepare for that moment and of course your penis reacts with an erection. I say mentally healthy because today men are so desensitized with adult entertainment, that a random thought or a woman in front of them is not enough to develop an erection. And physically of course because your penis is performing mechanically as expected upon receiving the signal from the brain.
Stay away from adult entertainment as much as you can. Convince yourself of finding pleasure in real life with a woman, or men depending on your preferences, and try to avoid finding pleasure with adult entertainment.
As far as PE, I believe your brain will train itself to recognize PE as exercise and not as preparation for reproduction. I had the same problem some 20+ years ago when I started PE. Back in those days I used to hang erected because of the same reason.