The installation of SMACH is pretty straightforward and it can be installed directly using the following command:
$ sudo apt-get install ros-melodic-smach ros-melodic-smach-ros ros-melodic-executive-smach ros-melodic-smach-viewer
Let's look at a very simple example to explain this concept.