Lots of questions. A lot of these questions are deep. And I could only summarize.
Your beginning question:
What I don’t do is type the exact location I want it to be installed from.
The package manager knows where and how to install the programs. This is required for the manager to know what is installed, and to keep the system clean. Linux uses the philosophy of one program should perform one task, and perform it well. When you install a program in Linux, the manager looks for what is required and installs the packages for you.
Where do the linux apps come from?
Most of the binaries come from the repositories. Some you build yourself from the source code.
Who ensures that those repositories have not been corrupted with malware?
The packages are signed by GPG private keys. This prevents anyone who is not the developer from publishing code under the same name. So the defender of the repositories are cryptography through mathematics. But in reality you need to trust the repositories. Don’t add random repositories. Using Ubuntu repositories are safe because you know who manages them.
I’m presuming that there are multiple repositories. And if so, how does my linux PC decide which repository to download a package from?
The maintainer of the Linux distro decides what respitory to use. With Ubuntu, each version gets a repository.
Do different distros all have the same repository, or different?
Different. There are many different Distros, Ubuntu uses the Ubuntu/Debian repositories, Red Hat uses their own. Just depends on the Distro.
If I’m using some full-featured latest release of Ubuntu, versus if I’m a light-weight version such as Puppy Linux, and I type the same exact command into terminal to install some app, will I be installing the same app in both cases, or different?
Each Distro uses a different way to access the repositories. For Ubuntu this is
apt-get
but on Red Hat this isyum
. Some Distros have a slightly different file structure and way of doing things. For example, Debian mother of Ubuntu, uses a completely different email agent than Ubuntu. One package manager will not work on all Linux Distros. Nor do we want this. A monopoly is bad for security and the freedoms that Linux brings.How is all of this handled so that the wrong version doesn’t get installed in the wrong place?
The package manager records all installed software (that the package manager installed). But sometimes this doesn’t work out (you might install from source), therefore, it really is the user that handles any issues.