APT will always install the latest version that isn't excluded by preferences. Preferences are indicated in the file /etc/apt/preferences (and in files under /etc/apt/preferences.d).
Some repositories have a configuration that prevents their packages from being installed automatically. For example, the Debian backports have release files (which you can see in /var/lib/apt/lists) that contain
NotAutomatic: yes
ButAutomaticUpgrades: yes
If you have multiple sources for the exact same package (i.e. same package name, same version number), then APT downloads from the first source found in /etc/apt/sources.list (or /etc/apt/sources.list.d/*; the files are searched in lexicographic order, and the sources are searched in order inside each file). So list local mirrors first. The order in sources.list is irrelevant for packages that have a different version number.
APT doesn’t manage package changes as transactions, so there’s no built-in operation to undo a package installation (or any other package manipulation). However, it does log all the operations it performs, grouped by end-user request: if you look in /var/log/apt/history.log, you’ll find the mypackage installation, along with a list of all the other packages which were installed automatically alongside it. You can use this to undo the installation manually.
You could also use aptitude instead, for your general package management: it effectively autoremoves by default. This won’t help you right now though since it will want to remove the same 166MiB of packages as apt autoremove.
As pointed out by Weijun Zhou, yum and dnf do manage package changes as units which can be undone (in some circumstances). dnf history will list the transactions stored in the history, and dnf history rollback or dnf history undo can be used to roll the history back or undo a specific transaction (if possible). I’m not sure yum or dnf can be used properly instead of APT on Debian-based systems; you might need to switch to Fedora, RHEL or CentOS if you want to use those tools for all your package management.
Best Answer
If you want the equivalent of apt-get or yum on Mac OS X, you have two choices.
You can use
brew install PACKAGE_NAME
orport install PACKAGE_NAME
to install the package available.