Hi J,
This is a quote from the Unity - Scripting API documentation for Rigidbody.velocity, linked below;
“In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour. Don’t set the velocity of an object every physics step, this will lead to unrealistic physics simulation. A typical example where you would change the velocity is when jumping in a first person shooter, because you want an immediate change in velocity.”
…and this is a quote from the Unity - Scripting API for a transform;
“Every object in a scene has a Transform. It’s used to store and manipulate the position, rotation and scale of the object. Every Transform can have a parent, which allows you to apply position, rotation and scale hierarchically.”
If you want your GameObject to be affected by physics then you’d add the Rigidbody component and, if you wanted to move it you could apply forces, the physics engine will then calculate where the object should be based on a number of factors and move it accordingly. If you don’t need to worry about physics, then you wouldn’t apply forces to it, you’d be setting the Is Kinematic property (assuming you still want the Rigidbody component for collisions etc), you’d then move the GameObject via its transform position.
Note, you could also use animation to move enemies side to side, this would be the same as setting the transform position yourself in code.
Hope this helps
See also;