Basically it’s about the state of the whole component. I searched for a fitting image but found also this article quite explaining.
levelup.gitconnected.com/componentdidmakesense-re…
For instance if you want to call an api and load data only on the first apprentice of an component then you use componentDidMount. If you have to clean up references (Timer or some external ones) use componentWillUnmount. I think you get the point. There is a method for every state of a component can get through.
Since the component is communicating about its state in the circle of life through these methods there’s no alternative to them. Other frameworks have similar paradigms.
For completion here are the official docs