Both LTE-M and NB-IoT are considered technologies of the 5G family. Technically they are way simpler versions of LTE, but they can coexist with "normal" 4G and 5G. A 4G / 5G base station can allocate part of its radio resources to these mobile technologies. In the future, with slicing this allocation can even be dynamic.
Most of the times, when people discuss how 5G will serve "massive machine type communications" they refer to LTE-M / NB-IoT.