How to make a mesh deform accurately along curves?
Try setting the twist parameter to 'Z-Up':



You can also manually control the tilt of the curve for each vertex or control point of it in the n-panel: