Leveraging Reasoning with Guidelines to Elicit and Utilize Knowledge for Enhancing Safety Alignment