Exploring the formation pathways of formamide