How does WordPress interpret the php code?

functions.php file of a theme gets includeed by WP as any PHP file, there is no special processing or anything.

So the code in the file just runs and what happens happens.

It is considered proper practice in WP that any code that doesn’t need to run immediately on boot should be instead hooked to appropriate point in load. Typically that is init (where core/plugins/themes load is considered mostly complete) and later hooks.