ZAP cannot attack parts of the target app if it does not know about them. Exploring the app is key - the more effectively that is done the more effectively ZAP will be able to attack it. This is why ZAP has so many options for exploring apps.
If you want to use ZAP for automated security scanning then you have a wide range of options, also listed on the main Automate page.
Also see the ZAP Chat 06 Automation Introduction video which talks about and demonstrates all of these options in more detail.
Each of these options provides a different balance between ease of use and flexibility + functionality:
It is not unusual for target systems to struggle or even fail when being scanned by ZAP.
This page explains what can go wrong, how to detect these problems and what can be done about them.
If ZAP cannot connect to the target app then it will typically fail very quickly. Solving connection problems will depend on the underlying cause, which ZAP will not be able to detect.