This is due to a fidget on the unit that controls idle behavior. Random animations, random turns.
Step by step how to find it in case you don't know how:
Open the data editor. Select Units. Find the unit you want to not randomly rotate while idle. Type "fidget" in the search box on the right. Here you can modify how the unit behaves while idle.