how do I get the user ID other than the one for the current logged in user?
Assuming that you're viewing a page at a path like /user/42, then you can use the RouteMatch class. Your example is close, but you need to change the parameter passed to the getParameter() method. The parameter in this case is named 'user' not 'node'. You can determine the parameter name from the route definition. Not all routes have parameters, but when they do, they are specific to the route in question.

In this case the route (entity.user.canonical) is defined by \Drupal\user\Entity\UserRouteProvider::getRoutes. And the 'user' parameter is the UID of the user entity in question. Given that, you can use RouteMatch to get the ID in one of two ways.

Load the $user object specified by the user parameter. Which is probably more common. I'm guessing if you're trying to get the UID it's so you can load the user object. With this method parameters are processed by the parameter conversion system, which does operations such as converting entity ID parameters to fully-loaded entities

$user = \Drupal::routeMatch()-&gt;getParameter('user');
$uid = $user-&gt;id();


Or access the parameter value directly:

$uid = \Drupal::routeMatch()-&gt;getRawParameter('user');


This change record provides a bit more information https://www.drupal.org/node/2295317