sometimes, if I want to install a program from the terminal, I get 2 options: apt and snap.
It can happen that the displayed versions are not the same, one candidate shows a higher version number than the other.
Do both libraries use the same numbering system and is it safe to assume that the higher the version number is, the newer the program is and one should only consider this variable to install new stuff?
Generally yes, but keep in mind that apt packages are maintained by canonical, while snap packages could be maintained by canonical, the apps’ original developers themselves (e.g. Firefox snap is maintained by Mozilla), or a 3rd party unrelated to canonical or the app’s developer (i.e. random dudes packaging apps into snap and submit them). If the snap packages are not maintained by canonical, there is nothing stopping the snap packagers to use a different versioning scheme, though it’s unlikely. In general, it’s a good idea to check the package entry on snapcraft.io to figure out who packaged them so you can decide if it’s trustworthy or not.