Technically you could decide to get married and go to city hall the next day for the marriage liscense and be set. No need for the engagement, although some might suggest that the time between deciding to get married and actually getting married, even in a matter of days, could be seen as a period of engagement.
if you choose to have a wedding, then it gives you time to prepare for the wedding and pubilicy states your intention to marry. It also publicy states you are not romantically availble to anyone else. It is an act of good faith.