As stated we.config is just a file and not executed. It can be read many times and many different sections of code.
With asp.net hosted by IIS, the first request to a application dir, the asp.net runtime will read the web.config, to configure the application. Once I the modules and handlers are loaded it will execute the pipeline. You asp.net code may read the web.config to get settings.
With .net framework console apps, there is typically an app settings. Again this read to get configuration information by the hosting code, then may be read after main is called to application settings.
With .net core reading the config files are optional. You add code to read them.