Despite it seeming like it when you are a teenager, sex is not really all mechanics. My husband used to joke that when he was a teenager, "all someone would have to do is look at my *** crosseyed and I'd get a hard-on," and the ready hormone flow of being a teen seem sometimes to provide endless proof of that. But I think teenagers today are more inured to sexual things than teenagers used to be when my husband was young, and are (and frankly this makes me hopeful for the human race) less likely to want sex without some kind of emotional connection, even the [traditionally randy] boys among them. They have so much opportunity that didn't used to be available, that it kind of brings them back to the notion that sex has to have some heart. So, one possibility is that you're not finding any real thrill in just mechanically *ing off.
Another possibility is stress, and/or depression, though sometimes people who are stressed or depressed actually do more masturbation because it is instant gratification. But if someone is generally under a lot of pressure and/ or depressed, it's possible that even sex is just not what it used to be for them. For that, see if you can find some assistance in checking the cause of your stress or lowered pleasure in life, and finding some coping mechanisms. In other words, not getting hard might just be an outflow of general other issues in life. It NEVER hurts to get help with general issues related to stress, anxiety or depression. It can be a huge comfort, in fact, just to have someone to talk to.
Another possibility is a low hormone flow for some other reason. For that, you could go to a doc and get your testosterone checked.
And finally, it might be "just one of those things" and will pass.
Good luck!