For Steam it’s just a default location within the Steam folder - you can actually choose anywhere.
As for other standalone programs, sometimes they put info into the registry for various purposes, but the more common reason is simply to provide a consistent installation process and location that people are used to.