Contextual links are used by the Contextual module to provide handy links next to a given component (a render array). You probably encountered this when hovering over a block, for example, and getting that little icon with a dropdown that has the Configure block link:
Contextual links are tied to render arrays. In fact, any render array can show a group of contextual links that are previously defined.
Modules can define contextual links inside a module_name.links. contextual.yml file, whereas other modules can alter them by implementing hook_contextual_links_alter().