Both realists and liberals believe that deterrence can prevent war. However, they differ on how potential aggressors should be deterred.
For liberals, the best source of deterrence is collective security. Liberals believe that aggressors can be deterred if they know that international bodies such as the UN will oppose them if they attack another country.
Realists do not believe that this will happen. They do not think that collective security will work. Instead, they believe that deterrence must be done by the actions of single states or self-interested coalitions of allies. In this view, the aggressor has to believe that some other country or alliance will attack them if they act aggressively. If that country/alliance is strong enough, the potential aggressor will decide that aggression is not in its interest.