I would add, per your details, you should focus on warming up. You didn't say if you warmed up, and you didn't say when you stretched or how you stretch -
the devil is always in the details. So perhaps you are warming up; but stretching cold muscles, or using the wrong stretches, is a disaster in the making and often contributes to pain during or after working out.
Your warmup should never, ever, (ever, ever, ever) consist of static stretching. I see so many people arrive for Taekwondo classes, plop themselves on the floor, then go into static stretches consisting of butterflies, hurdler stretches, and splits. Then they go into the ballistic stretches by kicking as high as they can. This is just as dangerous as going into a workout without properly warming up. The only time you might want to start your workout with a static stretch is when you are doing active static stretches your doctor might have ordered as you are on the mend from an injury; but then, your workout will be mild anyway. And still, there is no excuse for not warming up before that anyway. Tom Kurz (see link) and others will eventually have you go into your workout cold (no stretching, no warmup), but there is a science to it unrelated to your question, so I'll leave it at that.
Also, folks in traditional Karate don't really need nearly as much flexibility as we do in contemporary Taekwondo, because, Karate isn't about kicking high. You didn't say what the focus of your classes are like, and if your kicking has you doing them at or near your maximum range of motion, as that could be an indicator you're kicking too high for your conditioning and that you need to focus on more warmup and possibly less stretching.
Kids might not need to warm up much because they're usually active during the day anyway, but we adults often find our jobs (or college) leads to a somewhat sedentary lifestyle, and so, we should be sure we get a strong warm-up before working out. How much warm up depends on your current conditioning, perhaps a doctor can help here. But anything that gets the blood, breathing, and relevant muscles moving faster for several minutes would be the goal.
For me, in my 50's, I circumnavigate the parking lot to my Taekwondo and Aikido schools, both have large ones I walk around. I get there 30 mins early, walk the lot, then go in and do some dynamic stretching (not ballistic, and not static).
If I'm particularly warmed up from soccer practice that afternoon, or I know that I won't be doing high kicks, I might ask a partner to help with PNF / isometric exercises, which are workouts in of themselves.
One caution: whenever you do serious muscle workouts involving calf or thigh, you should be doing static stretches at the end of your workout; this helps alleviate aches the next day, which typically results from a buildup of lactic acid. The quad and calf statics can help squeeze the lactic acid out, and minimize build up which makes you ache later on.
And after any serious kicking, you should give at least a day's rest - no activity except dynamic stretches. This day of rest is how the body heals and is where your flexibility increases.
I find Tom Kurz's materials a great resource on dynamic stretching not only for increasing flexibility, but also for general health and maintenance overall.
Stadion Publishing
Alternatively, you might find PNF more suitable for your lifestyle. Here's a good and recent article on the subject:
PNF Stretching: A How-To Guide
There are tons of articles on both dynamic and isometric stretching, and some even conflict, and many don't agree on what ballistic or dynamic stretching are, so be careful what you read. Tom Kurz does go into anatomy, which is a great way to understand why one kind of stretching is good or bad over another kind, and with that understanding, you can more easily navigate another author's idea of what they mean with the various kinds of stretching.