Gradient Alignment in Physics-informed Neural Networks: A Second-Order Optimization Perspective