It means whatever the person doing the rating wants it to mean.
Usually it means that 40W of power may be dissipated, used, or supplied in association with the thing in some reliable fashion. i.e. a 40W light bulb will dissipate 40W of electricity as heat and light (at the rated voltage); a DC power supply rated at 40W will produce voltage and current combinations not exceeding 40W.
If you exceed the manufacturers rating, you can void guarantees.
In some cases, it means that 40W is the maximum sustainable power output, or input, of a device. i.e., a 3.5 hp lawnmower engine will run comfortably at 3.5 hp for a long time, but if you hook up a blower, and feed it nitro-methane, it will probably explode, due to its designed, self heat removal capacity, being overloaded.
In other cases, it means that the device will operate at 40W when hooked up standard fixed inputs. i.e., a 40 watt light bulb hooked up to 120 volts.
It also makes a difference if it's 40W peak or continuous.
For example some hand held power tools might be capable of delivering 300W for the time it takes to drive in a wood screw, but if you used one to power a push bike it's unlikely it would deliver 300W continuously for your 20 mile ride to work without overheating. The usage pattern matters.