The short version: legitimate under a prescription within defined limits, unapproved by definition, and quality depends entirely on the facility.
A compounded preparation has no marketing authorisation, no batch release by a qualified person and no pharmacovigilance obligation attached to it. That is the structural difference from a licensed product.
Additives are the other divergence. Preparations combining an active with vitamins or other agents are not equivalent to the approved product and have not been studied in that combination.
Beyond-use dating for compounded sterile preparations is governed by published standards keyed to the compounding environment.
The framework is jurisdiction-specific. Check yours rather than a general answer.