There are a lot of answers...
1) The IDE knows (from the project *.lpi file) which packages are used.
It will add the correct include path to the fpc commandline options when the IDE calls fpc. That is the path to the lib folder (.ppu and .o files).
Before that the IDE will have compiled the packages.
(That does not add anything, it just gives fpc the info where to find stuff)
2) When you add packages to the IDE itself, the ide creates (in your config folder) staticpackages.inc and that is included in lazarus.pp
So all packages appear in the "uses" list, and their "initialization" (section) code will be called.
(This adds the packages)
3) As for register:
Open the project ide/lazarus.lpi, the open a package you want to look at, and codetools will show you what happens ( Alt - Cursor Up )
This is called from the "initialization" section (see the generated file "packagename".pas // sometimes the name differs.)
The Initializiton call RegisterPackage, and gives a ref to @Register. And that will then be called at a later time.
Some of the called code may be in IDEIntf.
Check if a procedure is virtual. In that case the IDE may have instantiated a subclass, which overwrites the method.