Why is my object rotating oddly?
Before adding keyframes you need to apply the rotation using CtrlA.
You are experiencing a gimbal lock, which happens when two rotation axes coincide causing a loss of rotational freedom- in this case, the X and Z axes. This is because you have set the Y rotation value to 90, so applying it should solve the issue.
More on gimbal lock: https://en.wikipedia.org/wiki/Gimbal_lock