It depends on a lot of factors and how your project is made.
One simple way could be to add them the "Solid" and "8-direction" behavior.
The 8-direction will "bounce back" from the solid and prevent overlapping.
Nevertheless, if you are using something like pathfinding, it may also result in units never accessing their end target, and other issues like that.