The average or bulk properties of electromagnetic radiation interacting with matter are systematized in a simple set of rules called radiation laws. These laws apply when the radiating body is what physicists call a blackbody radiator.
Generally, blackbody conditions apply when the radiator has very weak interaction with the surrounding environment and can be considered to be in a state of equilibrium. Although stars do not satisfy perfectly the conditions to be blackbody radiators, they do to a sufficiently good approximation that it is useful to view stars as approximate blackbody radiators.