Macros expand to code at compilation. In the case of UVM factory macros, they expand to a lot of code (See this link as an example). Some of that code get executed at elaboration (parameterization). Some of that code gets executed at time 0 (static variable initialization). And some of that code gets executed if and when called (functions).