To get the node id you can use
$node->id(). Any object extending ContentEntityBase has this method.
You can look at the Node class to see what public getter methods are available (also, ContentEntityBase and Entity).
Note that protected values cannot be overwritten without a setter method - so you'll need to create a new variable from your preprocess hook to do this.
There are several options:
You can use the getter method for the node id (available for all entities):
You can use magic methods to access any field of any content entity:
The above code will actually trigger the below:
Debugging a content entity object is not very useful. Instead, debug its array representation (
$node->toArray()), you can access that data then like this:
$node->get('field')->property. For example
For base fields like the ID, there are usually also methods, in this case
$node->id() as mentioned by others.
See Entity API Cheat Sheet for more information.