it just takes time but learn the common drugs. the reality is that I prescribe a handful of antibiotics on a regular basis and there is a ridiculous number of antibiotics that I, nor anyone I know, have every prescribed. so learn that ones that are used. for example: clindamycin generally covers gram + and anaerobes, but no gram -. cephalosporins go up in gram - coverage generally speaking with every generation at the cost of gram positive. CNS penetration also goes up but they are inherently resistant to enterococcus. these ones cover MRSA, these ones cover pseudomonas. ampicillin covers this, augmentin adds this, Unasyn adds that, and zosyn covers that. meropenum is used when all isn't enough.
it is way to difficult to try to learn all of the stuff and it makes zero clinical sense in the real world. I have never ordered a first generation cephalosporin outside of cefazolin and cephalexin. I only order ceftriaxone as a third generation but sometimes order ceftaz in certain situations only. and cefepime when I want ceftiaxone plus pseudomanas. The list goes on. there is just no utility for a non ID doc to say "oh this rare bug is best covered by this specific antibiotic."
and probably the single biggest reason is that is how my hospital does it. a different hospital will do different antibiotics. so learn the major groups and coverages in a broad sense but as a student, understand that putting too much effort in the wrong thing is going to be a huge waste of time.