Drupal aggregates all the available library.yml files and passes them to the library.discovery.parser service. The default class for this service provider is \Drupal\Core\Asset\LibraryDiscoveryParser. This service reads the library definition from each library.yml and returns its value to the system. Before parsing the file, the parser allows themes to provide overrides and extensions to the library.
Libraries are enqueuers, as they are attached to rendered elements. Themes can generically add libraries through their info.yml files via the libraries key. These libraries will always be loaded on the page when the theme is active.
CSS style sheets are added to the data that will build the head tag of the page. JavaScript resources, by default, are rendered in the footer of the page for performance reasons.