Previous answers have focused on the fluid dynamics angle. However, you can also view it from a purely thermodynamic angle, viewing the rocket engine as a heat engine.
In order to get useful work (accelerated exhaust gases), you need some form of thermodynamic cycle with combustion followed by expansion. Due to conservation of energy, the amount of kinetic energy acquired by the gas will then be proportional to the amount of enthalpy (heat + pressure energy) that disapears as the exhaust gas expands and cools.
This means you want to maximize the temperature in the combustion chamber and minimize the temperature of the exhaust to maximize your Carnot efficiency. You ensure this by making sure that combustion happens before expansion, with a separate combustion chamber and expansion nozzle.
Furthermore, you want the gas to expand by as large of a factor as possible to minimize the exhaust temperature - and the expansion ratio is proportional to the area of the nozzle exit divided by the area of the nozzle throat. This means that from thermodynamic considerations alone, we can see that it is preferable to have a very tight throat and a very large exit area.
Fluid dynamics determine the exact details of nozzle shapes (de laval nozzles etc) that get the thermodynamic efficiency as close to the Carnot efficiency as possible, and whether the exhaust will actually expand or instead separate from the nozzle walls. But the need for a separate combustion chamber and nozzle is much simpler and can be understood without any knowledge of subsonic/supersonic flow.