I've been trying to learn to cook off and on for years now and I get so discouraged all the time because I'm still either overcooking or undercooking something, still not getting the flavors right, not using the right amount of oil despite the recipe's prescription. I can't be alone in feeling that way.
It took me years of cooking every day to get to a level where I'm confident in my cooking skills. It's a lot of trial and error. Look up a recipe that looks good, and try to follow it exactly. There's no eyeballing when you are learning. There's a reason those ingredients are added in that particular order and quantity.
I've come to a point where I can whip up a recipe and improvise some, but that's after years of following recipes, experimenting and eating a fair share of disappointing meals.
Learn the fundamentals. Binging With Babish on YouTube is an excellent show to learn with its Basics With Babish series.
Want to re-emphasize, cooking is a skill that's learned by repetition.
There are methods to help. Over cooking vs undercooking is because of guesswork. Remove that by buying an Instant Read thermometer. Over and under season? Taste as you go, add more seasoning if it needs it.
Also, make sure you find a consistently good recipe. Allrecipes is a crapshoot even though it's consistently a top Google search. Another poster mentioned Kenji Lopez who tests the crap out of his recipes. I'd also recommend Alton Brown having solid but accessible recipes. America's Test Kitchen/Cook's Illustrated and Bon Apetit for when you're getting more advanced. More beginner friendly stuff like Budget Bytes tends to be less flavorful, but typically simple enough and cheap enough you don't feel bad screwing up.
Basics with Babish is decent, at least the early episodes, for helping explain and visualize some of the basic skills.
But again, it's a skill that requires practice. I've been cooking consistently for years and I still can't spin up a recipe from memory or by feel. I mostly rely on trusted recipes and maybe do my own riff if I've done something similar before.
My experience was the complete opposite. Just relax and do whatever you want, the pan is your own little canvas. If something doesn't work out, oh well, you tried and learned from it.
I know you're getting a ton of responses, but if you do see this, look up Food Wishes on youtube. Would not be an exaggeration to say it has changed my life. 5-10m videos focused on one dish, usually including quite a bit of context and instruction aimed at beginners.
Cook with stuff you like! That way even if you screw it up you're left with stuff you mostly don't mind. Can't count the number of times I've screwed up meat sauce, and ended up eating a pound of meaty-tomato slop that tasted just fine albeit wasn't recognizable as any type of dish.
Also go easy on yourself. Recognize that this is a whole skill set that people spend their whole lives cultivating (just like software). You'll start to develop an intuition.
Make sure you have the right equipment you need too. I probably spent two years thinking I couldn't make eggs, turns out my pan was warped.
+1 to foodwishes. Most of my cooking knowledge comes from those videos. One thing that's hard to get from recipes is the actual cooking techniques, e.g. how loud onions should sizzle when you saute them. Foodwishes is great for learning and entertaining as well.
I've learned the most and gotten the most bang for the buck from using Cook's Illustrated special edition magazines. For example, Skillet Dinners1[1], my copy of which is well worn. The writeups that go with the recipes really help train one's intuition about cooking. Over time, I've gotten much better at knowing when to adjust ingredients or cooking times for a given recipe.
The best part of ATK and related Cook's country is they also helpfully go in-depth about the why. This helps you understand why the steps are laid out how they are. Plus it helps they test the crap out of their recipes so even with minor variation you can get a stellar end result.
My only complaint is sometimes they are way more steps and more exspensive sets of ingredients than other recipes. But often it's worth it for vastly superior results.
That's why I liked Serious Eat's Food Lab where Kenji also breaks stuff down but in an accessible set of recipes. Similar to Alton Brown's Good Eats, also a great resource if you like understanding the chemistry going on in your cooking!
ATK is great for beginners because they test their recipes and their recipe amounts are literally the same as they used in the tests.
A lot of recipes you find online are really guestimates on the amounts, so you never get the same result as the author. People are very bad about guestimating volumes, like "about 2 tablespoons of oil" when they really used half a cup.
Heh, I run into a lot of recipes where they have you cook in a tiny amount of oil and dump the pan out a couple times but you're still supposed to be "sautéing" whatever's in the last batch. Yeah, OK. Double the initial oil, add it again after each dump since there's still none left after the first time. Or else we're not doing what you claim we're doing, recipe. Which may also be fine, but still.
Or high-heat nonstick cooking with like one teaspoon of oil in the pan, heating it to nigh-smoke before adding anything else. LOL. Or steel or cast-iron temp + fat combos that make no sense and are guaranteed to give you a bad time. Either lots and lots of recipes are nonsense on this front, requiring modification of one form or another to be reasonable, or these people have magical pans that I do not.
A lot of the time I'll see recipes call for heating non-stick on a medium- or medium-high flame with so little fat in ("one teaspoon of oil" or some similarly-way-under-enough quantity) them that it only covers like 1/4 or less of the pan surface, so most of the pan is heating dry, which AFAIK is a great way to turn the coating into a gas that's fairly bad for you. Though maybe that's folk-wisdom and it's actually fine to heat a nonstick pan empty? IDK.
Learn your five basic tastes, most people don't get balance right, they can balance sweet and salty but they don't know how to balance sweet with sour and bitter with savory. Once you learn how to balance you can turn any dish into a flavorful dish. Learn your savory ingredients such as Soy Sauce, Truffles, Mushrooms, MSG, etc. Then learn your bitters, they are the hardest. If you make something too sweet balance it with lemon juice or vinegar. Too sour brown sugar, molasses. Too bitter use soy sauce.
As for overcook / undercook as other have suggested, get a good stick thermometer and use it religiously. I have cooked since I was 8 years old in a family of excellent cooks and went to culinary school and to this day I still use a thermometer.
Invest in a Thermapen instant thermometer (or less expensive Javelin) and a kitchen scale, these will make your life much easier and recipes more reproducible.
Also, can’t more highly recommend reading anything by Kenji Alt Lopez. A google of nearly any food you want to cook plus “kenji” will lead you to accurate, well explained, scientific based approach to cooking it. Or just pick up a copy of the Food Lab.
You're learning after-all, and learning while hungry is not a good combination. If you burn the food and then have to eat it, you're going to have a bad time, negative reinforcement, etc. Order something else, like pizza, munch on that as you learn this new skill of cooking.
I might try this more often. I'm currently trying to make a food schedule for things I know how to make every day of every week, and some of the new recipes I try are just not coming out all that well discouraging me to venture out on new recipes.
Yes, this. They are basically like magic for cooking proteins and vegetables. And the 'done' to 'overdone' margin of error can be hours instead of mere minutes.
Equipment matters, too. I thought I was cooking until I got a place with a gas stove and a great pan to match. Electric equipment just oscillates on/off at different rates and produces (un)predictably different results than modulating a constant intensity with fine control.
You might want to actually take cooking classes. Since you will learn the basics of saute, grill, heat. The right order of ingredients. Some of much of cooking is science and so much is just feel.