Out of the box, Drupal core offers lots of functionality and there are so many contrib modules available but sometimes it just is not perfect enough to fit the business need. Developers enjoy writing their own Drupal custom module, but sometimes it exposes the developer’s limitation or lack of awareness of the Drupal core. Drupal core does offer many features/functionalities and ideally one should restrain from writing their custom drupal module. In the long run it costs to maintain and it would require rewrite when upgrading the Drupal version. It can also run into issues when security patches are applied or upgrades performed during the regular course of maintenance.
Over the years, we’ve build small to enterprise level drupal modules and few involved customizing the existing contrib module. On few projects, we had to rewrite the custom module, since the client was upgrading from Drupal5 to Drupal7.