What happens with the cooking spray is it fill in the microscopic fissures that refract the light. It's a very temporary solution and doesn't correct the problem.
When you see the plastic start to haze from oxidation it's actually little micro fissures and particles that interfere and refract the light in different directions instead of the light passing through the plastic.
When you use a polish or compound you are doing a few things. Cleaning the debri that has fractured and sits on the surface from the micro fissure as well as smoothing the micro fissures so that they don't refract the light. In essence the polish or compound has fine particles that create abrasion on a microscopic level. This smooths out the larger microscopic anomalies so there is much less refraction of light and more light traveling in straighter path. The oils used in compounds and polishes fill even smaller fissures and give a straighter, better light path.
The toothpaste has baking soda that acts as a fine abrasive similar to the polishing compound but not as efficient and with out the better oils left behind.