When deploying functions via the Firebase CLI, by default
all of your functions are updated with each deploy. If you've changed the package.json in your functions directory, that means that functionA and functionB would both be updated to use the new dependencies. You can also deploy only a subset of functions:
firebase deploy --only functions:functionA
It's not clear from your original question what your setup looks like exactly, but only a single package.json (the one in your functions directory) is used. If you have other package.json files in subdirectories those will not be used to populate dependencies when you deploy.