Parameters in the HTTP request
Instead of inspecting the request object directly, the current_route_match service is the preferred object to consult for request parameters. It provides both the raw and upcast values of parameters. Additionally, using \Drupal\Core\Routing\StackedRouteMatchInterface you can retrieve values from the master request.

The reason you are having trouble with /comment/{comment} is because that route is special: it performs a subrequest to view the entity the comment belongs to. This explains why you only have the node entity available when viewing a comment on a node.

To work around this, consult the master request:

$comment = \Drupal::routeMatch()-&gt;getMasterRouteMatch()-&gt;getParameter('comment');