Get current node id from controller
Your route has no node parameter. See the documentation Structure of routes and the example from there:

book.export:
  # This path takes dynamic arguments, which are enclosed in { }.
  path: '/book/export/{type}/{node}'
  defaults:
    # Because this route does not return HTML, use _controller.
    _controller: '\Drupal\book\Controller\BookController::bookExport'
  requirements:
    _permission: 'access printer-friendly version'
    # Ensure user has access to view the node passed in.
    _entity_access: 'node.view'


You can access the route parameters in the controller directly in the function arguments:

public function bookExport($type, NodeInterface $node) {
  // get the id from the controller argument
  $node_id = $node-&gt;id();
}


\Drupal::routeMatch()-&gt;getParameter() is to get a route parameter outside of the controller, for example in a preprocess hook. For this to work the parameter has to be defined in the current route as well.