First you want to test ride the bike with your optimal saddle height.
Two questions related to bike fit:
- Can the handlebars be moved to an acceptable height? Most good bikes today have ahead stems so you can't simply untighten a bolt, move the bars and tighten a bolt but you must also re-adjust the headset. If the handlebar can't be moved high enough, consider a larger frame; if the handlebar can't be moved low enough, consider a smaller frame.
- Is the handlebar at an acceptable distance from the saddle? If it's too near, consider a larger frame; if it's too far, consider a smaller frame.
Sometimes you may not find a fitting bike using these methods and you need to swap the stem.
Other than that, I'd be looking at the opportunity to attach everything you need (lights, are there eyelets for fenders, does the U-lock fit in the main triangle, can you fit a kickstand, are there eyelets for rear rack). Then take a hard look at the geometry. My two concerns about geometry are if the chainstays are long enough (if not then panniers hit your ankles when riding) and if the bottom bracket drop is suitable (if bottom bracket is too low you'll hit the pedals to ground on corners, if bottom bracket is too high it's hard to mount and dismount). You should also check the standover clearance but usually that won't be an issue with modern bikes that have sloping top tubes.
The components can always be changed, but one of the most expensive components to change are the wheels so if the wheels have a suitable rim width, and enough many spokes to make them durable, it's always better. Extra points for hub dynamo should you need one. Also a wide enough range cassette could be good to have, because if it doesn't, you may need to change not only the cassette but also the chain to a longer version and rear derailleur to a longer cage version. With MTBs I'd also check that there is a large enough chainring.
With road bikes, I'd also be looking very hard at tire clearance. On other types of bikes (touring, gravel, cyclocross, MTB, hybrid) this usually isn't an issue.
The suspension characteristics of the bike should match what you need because suspension forks are long and rigid forks are short, so it isn't realistic to swap a suspension fork to a rigid fork that would be way too short for the geometry. I always prefer non-suspension bikes, and if I ride offroad then the suspension is obtained by choosing a fatbike with plenty of low-pressure air volume in tires.
Today the market seems to have decided that it's all disc brakes. I'm not entirely sure I agree with this decision, because rim brakes are good enough for 99% of purposes and actually often more rigid than disc brakes, offering a very nice braking feel. The only drawback of rim brakes is that in wet conditions, it takes two wheel revolutions (4.3 meters) to have full braking, but then again at 7 m/s speed you have 14 meters of reaction time. In anticipated stops, you already have cleared the rim of water in advance by lightly applying brakes early so the 4.3 meter penalty doesn't apply. In stops you have considered possible, you usually have lightly applied the brakes before you may have to stop, so the 4.3 meter penalty doesn't apply. The only problem is that in completely unanticipated stops your reaction time increases from 14 meters to 18.3 meters, hardly something to complain about. But it's very hard to find reasonable rim brake bikes today. About the only ones are road bikes that have no more than 23mm tire clearance (and to have reasonable tire clearance you need to choose disc brakes).
Don't compromise on the frame size unless your optimal size is inbetween two sizes (in which case you can choose either of the two), or if the sizes are closely spaced (2cm) in which case there probably are two that fit good enough.