The Art and Science of Compounding, is one that belongs to the pharmacist and has been so for hundreds of years. In fact, the very first practices of early pharmacists were just that, compounding medications for their patients. What that means, is to prepare, to formulate, to mix, make ready from basic chemical ingredients, a dosage form specific to the needs of a patient, as ordered by a practitioner. That practitioner might be a physician, a dentist, a nurse practitioner or a veterinarian.
What this then represents is the pharmacist or pharmacist technician under the direct supervision of a pharmacist, preparing a unique or custom dosage form for a specific patient to solve a specific therapeutic problem. That is a brief explanation of the process, but the "why" is a much more complicated answer.
Compounded medications may be the best choice when a commercial product is not available, or the particular dosage form not available. For example, a tablet dosage form may be available but a liquid format not. Therefore, to properly dose a child, the pharmacist would simply compound a liquid dosage form. That is a simple example, and that example could also be a cream or ointment dosage form that is not commercially available or not available in a particular strength needed to treat a particular problem.
Where the compounding becomes more complicated and more technologically complex is where a completely new or innovative dosage form is desired, to solve a particularly challenging therapeutic problem. In that case, the pharmacist must research the problem, present a solution, formulate a new dosage form, and then prepare the dosage form which could be a solution, cream, gel, oral capsule, rectal suppository, eye solution or injectable solution, just to name a few. The availability of so many innovative dosage forms is due to the influence of new technologies, processes and training, not previously available to the community pharmacist. An example of "going back to the future", in a different sense.