Alignment and Safety in Large Language Models: Safety Mechanisms, Training Paradigms, and Emerging Challenges