That is frustrating, but fortunately `HOMEBREW_NO_AUTO_UPDATE=1` will take care of it. Then you have to remember to update every now and then yourself, though.
Brew does not start randomly upgrading unrelated packages.
Packages have dependencies, and those dependencies have dependencies. Try `brew deps ---tree x` to see all the dependencies for you package.
Look at `brew pin` to pin packages you don't want brew to upgrade.
Many formula are versioned. For example if you install `postgresql` it will do major upgrades of postgres as they become available, but if you install `postgres@9.6` it will only install updates to 9.6.
I often do `brew upgrade X`. Brew indeed does what is necessary to upgrade package X + deps. But then goes on and starts upgrading unrelated packages.