When applications get installed they usually also install a so called “desktop file”.
Global location for distribution packages is /usr/share/applications on most distributions, user local default location is $HOME/.local/share/applications
Each application can list its URI scheme capabilities in its .desktop file, for example the steam.desktop file on my system has a line like this MimeType=x-scheme-handler/steam;x-scheme-handler/steamlink;
and the signal-desktop.desktop file has a line like this MimeType=x-scheme-handler/sgnl;x-scheme-handler/signalcaptcha;
As long as there is only one application for a given scheme that application is obviously also the default.
Now, if multiple applications have support for a scheme, the mimeapps.list file is consulted.
Its system default location is /etc/xdg/mimeapps.list and its user local default location is $HOME/.config/mimeapps.list
It can have a section called [Default Applications} with entries like x-scheme-handler/sgnl=signal-desktop.desktop
making signal-desktop.desktop the default for sgnl:// URIs.
On a tool level you can make use of xdg-mime to query and set such associations
“Tell me which application handles sgnl:// URIs” xdg-mime query default x-scheme-handler/sgnl
“I want Signal to handle sgnl:// URIs” xdg-mime default signal-desktop.desktop x-scheme-handler/sgnl