Most people think that a sail works only in one direction, thanks in part to the tall ships of the past.
What appears to be happening here is the wind is just pushing the sails and then in turn pushing the boat forward. But what actually is happening here is a vacuum.
As the wind fills in the sail it creates a high pressure system on the inside, the lack of wind on the front side of the sail creates a low pressure zone, and since systems move towards a lower pressure the boat gets pulled forward.
This also applies to modern boats and this lets boats go into the wind
You can see that the resultant force pulls the boat forwards, and so the boat would naturally get pulled sideways. This is solved with a board that is put directly beneath the boat so the sideways force it directed forward.