The recommended way is to use the software versions your distribution provides, i.e.
sudo apt-get install postgresql is correct. This might not always be the most recent version released upstream, but in most cases one doesn't really need the latest one.
If you (think you) need the very latest version of everything, you might want to use a distribution which is very fast with releasing new versions for its packages. E.g. while Ubuntu for many packages only releases new version upgrades with its half-yearly major update, Fedora more often adds new versions as updates to the current distribution incarnation. Other distributions like Gentoo give releases even faster. (However, all mentioned distribution gives security updates in a timely fashion of course.)
If you in general are happy by getting the latest versions, e.g. twice a year and only have one or two packages for which you need the latest and greatest, you can stay with Ubuntu or a similar distribution and either build the packages for which you need the latest version from source and install e.g. to /opt or /usr/local or you can try to get pre-build packages from the development tree of your distribution.