The Ballista is subject to the rules for making attacks in close combat
The rules for ranged attacks in close combat use the word "you" when dealing with who is making the attack, not "a creature" and so are not limited to only creatures.
This is because the rules are understood in relation to whomever is reading them. We know the creatures and objects in the book can't actually read the rules because they're not real (or are objects) but it's understood that the rules are a common and universally governing text.
Unless there's a specific rule which contradicts a general rule, the general rule applies and, in this case, "you" is applied in the general sense of an entity that is making a ranged attack because it is not specifically limited to creatures only.
Siege Equipment is dealt with on page 255 of the Dungeon Master's Guide. They are described as objects and the rules for using each one are described in their own section. To wit:
BALLISTA
Large object
A ballista is a massive crossbow that fires heavy bolts. Before it can be fired, it must be loaded and aimed. It takes one action to load the weapon, one action to aim it, and one action to fire it.
Bolt. Ranged Weapon Attack: +6 to hit, range 120/480 ft., one target. Hit: 16 (3d10) piercing damage.
The Ballista is not a creature but, as discussed previously, this does not matter. It is making a ranged weapon attack and therefore the rules about attacking in close combat apply.
Narratively, this makes sense. If a creature is attempting to aim the Ballista at a target immediately in front of it, it will be hard to hit. "But wait, if the target is standing point blank in front of the Ballista, it can't miss!"
The thing is, a creature is not it's space. A creature's space is the area that is controls, not the area it physically takes up. Think about aiming a ballista at a creature next to it. With a single or even a slight lean, the ballista's aim would be out of alignment. This difficulty is what is being captured by the rule about making ranged attacks in close combat and, understandably, it applies to siege weapons and creatures alike!
And if the Ballista is attacking some other target (not the adjacent hostile creature), the adjacent creature might be bumping into the Ballista or impeding some mechanism that allows it to operate optimally.