Basically, it's happening because you're 18, and your hormones are still all fluctuating all the time.
It will stop when your body stops changing.
Are you taking any kind of performance enhancing products? Often, those include testosterone and other hormones, and those might be causing these issues, too.
One thing you might try is masturbating before a game or practice or whatever. That might help your body not get erections as often when it's not ideal for you to get them. Some guys do that before going on a date so that they don't get erections when kissing goodnight or at inappropriate times.
If you are taking any kind of performance enhancers/health products, check to see what is in them. If any hormones are in them, look for other products.