Sometimes when I look at the Moon and Sun, the crescent is not aligned with the Sun correctly. What is going on?

Very interesting. I had not noticed this phenomenon, but there should be no reason I can think of geometrically, why the crescent should not exactly be bisected by the line joining the center of the Moon and the center of the Sun in the sky.

Your perspective can get fooled because the sky is a spherical screen onto which motions and orientations are projected. To determine true orientations, you have to work out the spherical geometry of the particular line that bisects the center of the Sun and the center of the Moon, and with respect to that 'geodesic' line on the sky, the lunar crescent will always be exactly bisected.