The key to hiking safely alone is also the key to hiking safely at any time, whether with or without others: identifying dangers correctly and successfully avoiding or mitigating them, through good preparation and good judgment. If you can do this consistently, you will hike safely.
As far as I can see, hiking with another person does not guarantee that any of those safety factors will be increased, and if the other person has bad judgment, or is ill prepared or overconfident, they are more likely to get you into trouble than make you any safer.
About the only thing that having others around will guarantee is that, once you have failed to recognize and avoid a danger, and consequently have injured yourself, or become hypothermic, or lost, there will be another person who might assist you in extracting yourself to a place of safety or can administer aid. But this, as I say, is the case only after you've failed in your primary task of keeping yourself safe, sound and whole. In other words, it didn't make you safer, but only makes it easier to rescue you from your failure.