For years I bought trousers the way I bought melons, a hopeful squeeze and a quick guess, which is how I ended up with three pairs that looked fine on the hanger and did something strange and baggy at the knee by lunchtime. What sorted me out was finally handling the fabric properly before buying, not just eyeing it from a rail, because that's where most of the information actually is.
A good pair tells you what it is the second you touch it. The fabric should have some body to it, enough that it holds a crease or a straight line without needing you to iron it into submission every morning, and it shouldn't feel thin enough to show the shape of your pocket lining through the front. Check the inside too. A proper waistband has a bit of structure to it, maybe a curved facing or a touch of interfacing, rather than just two layers of the outer fabric stitched together and left to go soft and roll over by evening. Seams should sit flat, not puckered, and the hem should hang the same length front and back, which sounds obvious until you own a pair that doesn't. Hardware matters more than people expect, a flimsy zip or a button that needs pliers to do up is usually the first sign the rest was made just as carelessly.
If you own none and want one pair that earns the space in your drawer, go for a straight leg in a mid weight fabric, in black or a dark navy rather than anything trend led. It sits well with a jumper, with a shirt, with trainers on a bad day and heeled boots on a better one, and it doesn't shout at the rest of your clothes. Wide leg is lovely but needs a bit more commitment, and anything very fitted shows every lunch decision by three in the afternoon, which is a fine thing to know about yourself before you buy it, not after.
In the shop, sit down in them before anything else. Walk a few steps, properly, not a little shuffle near the mirror. Check the rise doesn't gape at the back when you bend, check the waistband doesn't dig when you sit, and look at the fabric under the shop lights because polyester blends can go slightly see through under strong light in a way you won't notice until you're stood at a bus stop regretting it. A small stretch percentage, even two or three, makes a huge difference to how the day actually feels in them. And a good pair, once you've found it, has that particular pleasure of sitting down at the end of a long day and realising the waistband never once told on you.