If you read the documentation for getcollidingbodies() function, you'll realize it's not the best suited function to use to detect collisions for a RigidBody2D, and that it is working as intended by returning an Array of colliding bodies. I'd strongly advise you to use either RigidBody2D's bodyentered and bodyexited signals or directional raycasting, e.g. having multiple RayCast2D nodes, and checking their collisions each physics tick. Or additionally use Area2D that has a slightly bigger cillision than your RigidBody2D and it's bodyentered and bodyexited signals. Also set-up physics layers, so you can use collision layers and collision masks to avoid checking for collisions where it's not needed.
It's hard to give you the right answer without really knowing what is your intention and what kind of collision are you checking for. You can read up more about your use case here RigidBody2D documentation.