The players usually control their characters and use of class features, but this is not their character
the PHB says on page 5:
The DM creates adventures for the characters, who navigate its hazards and decide which paths to explore. The DM might describe the entrance to Castle Ravenloft, and the players decide what they want their adventurers to do.
Unless a feature explicitly says something different, the players decide how to use it. But they get to decide what they want their adventurers to do. The companion is a class feature of the Ranger character, but is not the character themselves, so this is a special situation where the creature is not the adventurer, even though it is part of a class feature. So the DM could decide to run them, or let the player run them.
For comparison various spells that summon creatures as part of the character's Spellcasting feature say:
If you don’t issue any commands to them, they defend themselves from hostile creatures, but otherwise take no actions.
Here, the feature tells you how the creature behaves. The companion feature does not do that.
Some DMs will be happy to let you control the behavior. Other DMs generally reserve the right to control any creature other than the actual player character themselves unless the rules explicitly call out where or when the character can control their actions, so check with your DM how they handle it.