Basically, you actively and thoughtfully manage the environment for your pet. You frequently expose your animal to varied environments, and you don't assume that just because your pet has met one man and liked him, that he will like all men thereafter. You must assume that your pet does not generalize, and you must expose to many, many things. Helping to create pleasant situations is also animal-specific. If your animal is food motivated, or really enjoys getting treats, you can classically condition your animal to environments by giving treats during exposure.
Classical conditioning is a powerful tool.
For example, your animal sees a car passing by and tries to rush away. Imagine that you are out in the woods and suddenly, overhead, an unexpected fireworks display begins. You have never seen fireworks in your life, don't realize they exist, and initially you are very scared. However, you can't get away from them this day, you try to run and hide, but you can't. The display goes on for four hours.