Penicillin and related antibiotics (like cephalosporins) work by inhibiting the synthesis of peptidoglycans, which are essential components of the bacterial cell wall. This weakens the cell wall, leading to cell lysis and death, particularly in growing bacteria.