Coal mine accidents seriously affect China's coal safety production and sustainable development. The present study aimed to reveal the risk factors in coal mine accidents and explore the causal relationship among risk factors. This study utilized text mining to analyse 450 coal mine accident reports, identifying 50 risk factors and efficiently mapping them into the 24Model. The association rule algorithm was then used to mine the strong association rules among the risk factors within the 24Model, establishing the interaction mechanism among them. Based on the strong association rules, related hypotheses were proposed. Finally, the hierarchical and logical relationships of risk factors within the 24Model were analysed, and the causal and mediating effects were tested by path analysis. The safety management system has a direct effect on unsafe acts, unsafe conditions, habitual behaviour and organizational safety culture. Moreover, external influence has an effect on unsafe acts, organizational safety culture and habitual behaviour through the mediating effect of the safety management system. Based on the results obtained, this study proposes a series of specific measures to prevent risks in coal mines, providing a new perspective for the analysis and prevention of accidents.