In these situations, the sails propel the boat by redirecting the wind coming in from the side towards the rear.
In these situations, the sails act as airfoils. They redirect the wind coming in from the side towards the rear.