The formation of N-nitroso compounds typically involves the reaction between secondary amines or amides and nitrosating agents like nitrites. This reaction can occur in acidic environments, such as the human stomach, especially when dietary nitrites are consumed along with amine-rich foods. Environmental factors such as temperature and pH can influence the rate and extent of nitrosation.