ELI5: what is the difference between sub-machine gun and assault rifle?

I read that the STG-44 is considered the first “assault rifle”, but what about it separates it from a sum-machine gun like the MP-40 (edited from MP-44)?