Rubbing your penis up and down in bed must be sort of an ancient reflex for I'm sure a lot of us got started that way. But I have heard that over time that activity could be harmful -- better just to lie on your back, take your penis loosely in your hand and start stroking. And at age 24 even a couple of times a day would not be unusal or harmful.
I say to hold your penis loosely -- you say you haven't had sex yet and I imagine that you mean with someone else, since masturbation, beating off, whatever you want to call it is a type of sex -- since a woman's vagina is not going to be as tight as your hand and you don't want to be training yourself to expect always to have something tight surrounding your penis while you are having sexual enjoyment. Also, even though your hard penis may feel strong and mighty it is still something which can be injured by rough handling. And hurting yourself is definitely something to avoid.
And one more thing -- I would suggest you work at finding a variety of ways to excite yourself while masturbating. Don't do it exactly the same way all the time. You need to be able to adjust to different situations -- or people -- over time and you need to be skilled at pumping to ejaculation in a variety of ways.
Good luck, keep at it and make sure you enjoy. And maybe you'll stop having thoe times when you feel bad about doing it -- it's a good activity, something which men do.