What Makes and Breaks Safety Fine-tuning? A Mechanistic Study