Spraying is a territorial behaviour, and is most common (but not only) seen in cats that are not neutered or spayed. Spraying will generally be against vertical surfaces and is a way of marking a territory or sending a signal to other cats. Thus, it is more common in multiple cat households. Spraying tends to begin at the age of sexual maturity (4-6 months old) in cats that have not been de-sexed and will generally occur when cats are feeling threatened or stressed.
De-sexing the cat helps in the majority of situations and ideally should be done before they are 4-6 months old. If your cats are spraying around external doors or windows they may feel threatened by neighbouring cats so do what you can to prevent encouraging other cats near your house.