In Drupal 7 if you wanted to tweak the functionality of an existing function then an alter hook was your best friend, but in Drupal 8 it's "all change!"
With the introduction of Symfony, your new BFF is an Event Subscriber. Alter hooks still exist, but it is recommended that we all move towards Events to fall in line with Symfony.
If you are interested in the comparison between alter hooks and events then I recommend this article from PreviousNext.
In just 4 simple steps, this article will talk you through the process of writing a custom Event...