how to animate only position.x component of transform

i am trying to animate 2d objects via animation.
say i have a truck sprite and i want it to go forward rotate 180 deg and come backward

i have animated the x component of position and z component of rotation.

but,the y and z component are automatically included for position property. even after deleting there key frames both the property are assumed to be 0. for all frames.

what i want is if I instantiate the truck object anywhere on the screen only the x component gets affected .
but in my case the y and z are turning to 0 on there own.

Because you added the position property in your animation, even after you delete the keyframes it will still be assumed to be 0. a good practice when using the animation/animator components is to parent the visual to a parent gameobject. Then you can move the y and z components independently in your parent gameobject