Antibiotics are a big group of drugs. They all work differently, but what they all have in common is that they specifically target a certain part of bacteria. So by definition, antibiotics can only be used on infections that are caused by bacteria. Penicillin, for example, specifically targets an enzyme that bacteria need to build their cell wall. Without that wall they burst and die. If you'd use penicillin on a protozoa, like the one that causes malaria, it wouldn't work because they don't rely on a cell wall and don't have the same enzyme.