From the manual:

material.event
This function is called once for every entity this material is assigned to as long as ENABLE_VIEW or ENABLE_RENDER aren't set.

If zero entities are assigned to the material, the event is executed zero times. What you probably want to use is a starter function, not an event function.