Install one small tool on Ubuntu and sometimes apt wants thirty other packages. A lot of those are only recommended, not required.
You can tell apt to skip them:
sudo apt install --no-install-recommends
The man page describes the option as keeping recommended packages from being treated as dependencies. What stays is the hard dependency chain, so the program installs and runs.
I would check first with a simulation. Add -s and apt prints what it would do without touching anything:
apt-get -s install
apt-get -s install --no-install-recommends
Compare the two lists. On a headless server or a minimal container the second one is often much shorter, which means less to patch later.
It is a habit I like for servers more than for desktops. A server should do one job, and every extra package is something else that needs patching.
The caveat: recommended means the maintainers thought most people want it. Fonts, documentation, plugins, sometimes a feature you assumed was built in. If something is missing afterwards, install it by name.
Further reading: apt-get(8) man page (Ubuntu 24.04), On this site: apt autoremove –purge also deletes the leftover config files, On this site: apt changelog shows why a package wants to update