i noticed however that when i run the Update command from the RetroPie setup script, cmake is reverted to 3.13 again. Apparently it does not detect that a higher version is already installed, cause i also noticed that cmake and cmake-data are installed again as raspbian packages.
It does not detect it, because it's not installed from a .deb package. RetroPie installs the cmake package that's available in the distro - whatever version is available in the Raspbian repositories.
As a general rule when installing from source - in order to not get your installation overwritten by a distro package, don't install into the system directories (/usr/bin, /usr/sbin, etc.) - use /usr/local or /opt.