The short answer: buy off-the-shelf software when your process is broadly standard and a product fits most of what you need. Build custom software when your process is specific enough that products force constant workarounds, when several tools need to share data none of them handles well, or when subscription costs have grown large enough to justify owning the system.
Because the most expensive mistake in this area is building something a product already does well.
With a packaged product, your business adapts to the software's assumptions. With custom software, the software adapts to your business. Neither is inherently better. Adapting to a well-designed product can improve a process. Adapting to a poorly fitting one creates workarounds, side spreadsheets and re-entered data.
Off-the-shelf:
Custom:
Compare both over several years, not just the first.
Many businesses don't need to choose one or the other. Common hybrids:
If the answers point toward a product, buy the product. If they point toward custom, start with the smallest phase that removes the biggest problem.