There are too many types of medication to give a general recommendation.
There are certain medications, like those that use the ingredients malachite green or formalin that are very hard on invertebrates (snails, shrimp) and are harder on scaleless fish (catfish, loaches) and softwater fish (cardinal tetras, German Blue Rams, discus). These are also tough on plants. I would advise against treating in a community tank unless it is thought the root problem affects all the fish and the fish are likely to tolerate it at the necessary dose. These two ingredients can kill your nitrifying bacteria, but they may not.
Antibiotics (kanamycin, erythromycin, tetracycline, others) are generally better tolerated by a wider variety of critters and under the right circumstances are relatively safe to apply to an entire aquarium. With that said, some of them will kill your nitrifying bacteria, thereby un-cycling your aquarium and making it likely that you will deal with persistent ammonia spikes that will kill or badly harm your fish. Research the ingredient carefully to assess the risk here.
Copper is an ingredient that can be very effective for certain ailments but again is tough on scaleless fish and in general kills fish if overdosed. It is absolutely lethal to invertebrates and is difficult to remove from the tank. Even just trace amounts left over from treatments long ago can kill snails and shrimps. I would never apply copper to a community aquarium.
There are some anti-parasitic medications, like metronidazole and praziquantel, that are very mild and shouldn't pose serious risks in a community tank. I still wouldn't put them in a tank unless I felt certain that some of the fish needed it; I wouldn't put them in a tank as a purely precautionary measure.
As a general rule, find out what the medication's active ingredients are, read through the warnings and recommendations of the manufacturer, and then research the ingredients individually to learn from other aquarists and sources.